How to parse the xml file in vim?


I am currently working on an android project. And now i wish to complete a job: Parsing a xml file called AndroidManifest.xml and get some attribute from it. And set to some values in vim.

Here is the AndroidManifest.xml file.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
      <uses-permission android:name="android.permission.READ_CONTACTS" />
      <uses-permission android:name="android.permission.WRITE_CONTACTS" />
      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
      <application android:label="@string/app_name"
        <activity android:name="HistoryMainActivity"
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />

        <activity android:name="HistoryListActivity">
                <category android:name="android.intent.category.LAUNCHER"/>

        <activity android:name="DetailListActivity">
                <category android:name="android.intent.category.LAUNCHER"/>


I want to parse package="com.base.module.callhistory" and HistoryListActivity in <activity android:name="HistoryMainActivity". Then i can use this two value to compose a command to launch my app automatically. I just set these values by hand. But i think if vim can parse this file and set these values automatically, it's must very cool.

Consider xmlstarlet, xmllint --xpath

Otherwise, you can use perl or python to achieve your goal if you have it compiled in (usually packaged versions do)

Regardless of that, you might still use nomarl search (/) patterns with c i t to replace the tag contents