XML tag name content replacement | Unix Linux Forums | HP-UX

  Go Back    


HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

XML tag name content replacement

HP-UX


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-28-2013
periyasamycse periyasamycse is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 26 September 2013, 8:22 PM EDT
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
XML tag name content replacement

Hi,

Need to replace an XML tag name contents, please provide any suggestions.

Scenario is :

Code:
<abc_def>Value_some_content</abc_def>

Expected output :

Code:
<abc:def>Value_some_content</abc:def>

We have many tag with different names & contents in a file or a string.
Please help on the above.

Thanks.

Last edited by Scott; 01-28-2013 at 02:02 PM.. Reason: Please use code tags for code and data
Sponsored Links
    #2  
Old 01-28-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 24 April 2014, 6:15 PM EDT
Location: Galactic Empire
Posts: 3,285
Thanks: 227
Thanked 1,158 Times in 1,095 Posts

Code:
awk -F'<' '/^</{sub("_",":",$2);}/>$/{sub("_",":",$NF);}1' OFS='<' xmlfile

The Following User Says Thank You to Yoda For This Useful Post:
periyasamycse (01-28-2013)
Sponsored Links
    #3  
Old 01-28-2013
itkamaraj's Avatar
itkamaraj itkamaraj is offline Forum Advisor  
^Kamaraj^
 
Join Date: Apr 2010
Last Activity: 19 April 2014, 1:02 AM EDT
Posts: 3,044
Thanks: 33
Thanked 653 Times in 632 Posts

Code:
$ echo '<abc_def>Value_some_content</abc_def>' | sed 's,abc_def,abc:def,g'
<abc:def>Value_some_content</abc:def>

    #4  
Old 01-28-2013
periyasamycse periyasamycse is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 26 September 2013, 8:22 PM EDT
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks bipinajith..

@itkamaraj : i have so many tags with different contents in the xml file.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to add the multiple lines of xml tags before a particular xml tag in a file mjavalkar Shell Programming and Scripting 0 06-25-2012 04:54 PM
How to retrieve the value from XML tag whose end tag is in next line mjavalkar Shell Programming and Scripting 3 05-03-2012 02:12 AM
XML tag replacement from different XML file balrajg Shell Programming and Scripting 0 01-25-2011 10:00 PM
sed, awk [TAG]$content[/TAG] How to get var in $content in textfile? atmosroll Shell Programming and Scripting 7 03-05-2010 05:27 PM
how to get xml tag.. forevercalz Shell Programming and Scripting 8 01-15-2006 07:46 PM



All times are GMT -4. The time now is 07:39 PM.