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 03: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: 21 November 2014, 11:17 AM EST
Location: Galactic Empire
Posts: 3,389
Thanks: 235
Thanked 1,210 Times in 1,136 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-29-2013)
Sponsored Links
    #3  
Old 01-29-2013
itkamaraj's Avatar
itkamaraj itkamaraj is offline Forum Advisor  
^Kamaraj^
 
Join Date: Apr 2010
Last Activity: 14 November 2014, 7:56 AM EST
Posts: 3,059
Thanks: 33
Thanked 659 Times in 638 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-29-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 05: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 03:12 AM
XML tag replacement from different XML file balrajg Shell Programming and Scripting 0 01-25-2011 11:00 PM
sed, awk [TAG]$content[/TAG] How to get var in $content in textfile? atmosroll Shell Programming and Scripting 7 03-05-2010 06:27 PM
how to get xml tag.. forevercalz Shell Programming and Scripting 8 01-15-2006 08:46 PM



All times are GMT -4. The time now is 03:51 PM.