Insert a new subnode in a xml file

Hi,
i have an xml file and i want to edit a new sub node in a file
like

val="<activity android:label="@string/app_name" android_name=".MainActivity1" android:launchMode="singleTask" android:screenOrientation="portrait"
               android:configChanges="keyboardHidden|orientation"><intent-filter><action android_name="android.intent.action.MAIN"/>
                 <category android_name="android.intent.category.LAUNCHER"/></intent-filter></activity>"

i am using this command

xmlstarlet ed --subnode "/manifest/application" --type elem -n "$val" -v "" AndroidManifest.xml > and.xml

command running fine but new generated xml file is wroung because it add some more tag like :-

<<activity xmlns:android="http://schemas.android.com/apk/res/android" android:label="@string/app_name" 
           android_name=".MainActivity1" android:launchMode="singleTask" android:screenOrientation="portrait" 
          android:configChanges="keyboardHidden|orientation"> <intent-filter> <action android_name="android.intent.action.MAIN"/> 
         <category android_name="android.intent.category.LAUNCHER"/> 
     </intent-filter> </activity>></<activity xmlns:android="http://schemas.android.com/apk/res/android" 
        android:label="@string/app_name" android_name=".MainActivity1" android:launchMode="singleTask" android:screenOrientation="portrait" 
       android:configChanges="keyboardHidden|orientation"> <intent-filter> <action android_name="android.intent.action.MAIN"/> 
       <category android_name="android.intent.category.LAUNCHER"/> </intent-filter> </activity>>

how can i edit this. pls help me

Well, it made a mess of it! You have two of the original, probably one from the file and one from $val, and some <> ! XML is not that hard to edit by hand, if you know what you want to add. I recommend indenting and linefeeds to make the structure easy to see.