Sponsored Content
Top Forums Shell Programming and Scripting Insert a new subnode in a xml file Post 302745779 by gautamshrm3 on Tuesday 18th of December 2012 04:18:15 AM
Old 12-18-2012
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
Code:
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
Code:
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 :-
Code:
<<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

Last edited by jim mcnamara; 12-18-2012 at 01:02 PM.. Reason: Please use code tags for data and code samples jmc - readability
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script to run shell command and insert results to existing xml file

Hi. Thanks for any help with this. I'm not new to programming but I am new to shell programming. I need a script that will 1. execute 'df -k' and return the volume names with specific text 2. surround each line of the above results in opening and closing xml tags 3. insert the results of step... (5 Replies)
Discussion started by: littlejon
5 Replies

2. Shell Programming and Scripting

Insert value of env variable in xml file

Hello, I have the following variables set in my env echo $MY_XSD_FILE /home/jak/sample.xsd echo $MY_INTERVAL_VALUE 4 I want to insert them between the xml tags in my xml file cat sample.xml ::::::::::::::: ::::::::::::::: <property name="FILE"></property> :::::::::::::::::::::::... (2 Replies)
Discussion started by: jakSun8
2 Replies

3. Shell Programming and Scripting

Insert a new line between the XML tags?.

<TestLog> <TriggerAPI> <StartDate>Nov 16, 2012 6:34:02 AM com.satttest01.Response() </StartDate> <RequestType>SUCCESS: Send :</RequestType> <TranNumber>5210203</TranNumber> <TranId>8585319731207148</TranId> </TriggerAPI> <TriggerAPI> <StartDate>Nov 16, 2012 6:34:02 AM... (3 Replies)
Discussion started by: laknar
3 Replies

4. Shell Programming and Scripting

From sql Insert Query to XML format

Hi How do I translate Let say Cat inserts.sql gives Insert into PM9_TAXATION_ROUNDING (STATE_GECODE, TAX_TYPE, TAX_AUTHORITY, SYS_CREATION_DATE, SYS_UPDATE_DATE, APPLICATION_ID, DL_SERVICE_CODE, ROUNDING_METHOD) Values ('xx', 'xx', 'x', TO_DATE('10/26/2012 13:01:20',... (3 Replies)
Discussion started by: anuj87in
3 Replies

5. Shell Programming and Scripting

Insert a newline in XML

Hi guys, I got a requirement that ... (5 Replies)
Discussion started by: mohanalakshmi
5 Replies

6. Shell Programming and Scripting

awk command to insert a tag in XML

Hi All, I need a help on inserting a XML tag. Actual input <var> <nam>abcd</nam> <a1>.</a1> </var> if tag <a1>.</a1> is getting missed in XML like below <var> <nam>abcd</nam> </var> i need to insert wherever it is missed after <nam> tag and before </var> tag. Could anyone... (3 Replies)
Discussion started by: mohanalakshmi
3 Replies

7. Shell Programming and Scripting

How to insert new line in xml?

I have an xml like below and wanted to insert a new line between end of the tag and start of the new tag. <partyaddress><addressline1>gandhi stree</addressline1><city>hyderbad</city><state>AP</state><addressline1>xyz stree</addressline1><city>bangalore</city><state>Karnataka</state>... (6 Replies)
Discussion started by: D_Sethi
6 Replies

8. Shell Programming and Scripting

Insert text after match in XML file

Having a little trouble getting this to work just right. I have xml files that i want to split some data. I have 2 <name> tags within the file I would like to take only the first tag and split the data. tag example. From this. TAB<Name>smith, john</Name> to TAB<Name>smith,... (8 Replies)
Discussion started by: whegra
8 Replies

9. Shell Programming and Scripting

How to insert a CSV within xml element tag using Python?

Hi Team, I have a CSV file which I have to read through and needs to insert the content within an XML file using Python ONLY ( as most of the code base we have in python only). I managed to find the first part, missing how to insert to XML under "specific" tags. cat input.csv... (0 Replies)
Discussion started by: panyam
0 Replies

10. UNIX for Beginners Questions & Answers

How to insert subnode in xml file using xmlstarlet or any other bash command?

I have multiple xml files where i want to update a subnode if the subnode project points to different project or insert a subnode if it doesn't exist using a xmlstarlet or any other command that can be used in a bash script. I have been able to update the subnode project if it doesn't point to... (1 Reply)
Discussion started by: Sekhar419
1 Replies
Test::XML::Simple(3pm)					User Contributed Perl Documentation				    Test::XML::Simple(3pm)

NAME
Test::XML::Simple - easy testing for XML SYNOPSIS
use Test::XML::Simple tests=>5; xml_valid $xml, "Is valid XML"; xml_node $xml, "/xpath/expression", "specified xpath node is present"; xml_is, $xml, '/xpath/expr', "expected value", "specified text present"; xml_like, $xml, '/xpath/expr', qr/expected/, "regex text present"; xml_is_deeply, $xml, '/xpath/expr', $xml2, "structure and contents match"; # Not yet implemented: # xml_like_deeply would be nice too... DESCRIPTION
"Test::XML::Simple" is a very basic class for testing XML. It uses the XPath syntax to locate nodes within the XML. You can also check all or part of the structure vs. an XML fragment. TEST ROUTINES
xml_valid $xml, 'test description' Pass an XML file or fragment to this test; it succeeds if the XML (fragment) is valid. xml_node $xml, $xpath, 'test description' Checks the supplied XML to see if the node described by the supplied XPath expression is present. Test fails if it is not present. xml_is_long $xml, $xpath, $value, 'test description' Finds the node corresponding to the supplied XPath expression and compares it to the supplied value. Succeeds if the two values match. Uses Test::More's "is" function to do the comparison. xml_is $xml, $xpath, $value, 'test description' Finds the node corresponding to the supplied XPath expression and compares it to the supplied value. Succeeds if the two values match. Uses Test::LongString's "is_string" function to do the test. xml_like_long $xml, $xpath, $regex, 'test description' Find the XML corresponding to the the XPath expression and check it against the supplied regular expression. Succeeds if they match. Uses Test::More's "like" function to do the comparison. xml_like $xml, $xpath, $regex, 'test description' Find the XML corresponding to the the XPath expression and check it against the supplied regular expression. Succeeds if they match. Uses Test::LongString's "like_string" function to do the test. xml_is_deeply_long $xml, $xpath, $xml2, 'test description' Find the piece of XML corresponding to the XPath expression, and compare its structure and contents to the second XML (fragment) supplied. Succeeds if they match in structure and content. Uses Test::More's "is" function to do the comparison. xml_is_deeply $xml, $xpath, $xml2, 'test description' Find the piece of XML corresponding to the XPath expression, and compare its structure and contents to the second XML (fragment) supplied. Succeeds if they match in structure and content. Uses Test::LongString's "is_string" function to do the test. AUTHOR
Joe McMahon, <mcmahon@cpan.org> LICENSE
Copyright (c) 2005 by Yahoo! and Joe McMahon This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.1 or, at your option, any later version of Perl 5 you may have available. SEE ALSO
XML::XPath, Test::More, Test::Builder. perl v5.14.2 2012-06-05 Test::XML::Simple(3pm)
All times are GMT -4. The time now is 10:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy