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

  Unix/Linux 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 Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 01-28-2013
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 30 March 2015, 11:20 AM EDT
Location: Galactic Empire
Posts: 3,401
Thanks: 240
Thanked 1,215 Times in 1,141 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 Unix and Linux 01-28-2013
itkamaraj's Unix or Linux Image
itkamaraj itkamaraj is offline Forum Advisor  
^Kamaraj^
 
Join Date: Apr 2010
Last Activity: 30 December 2014, 10:04 PM 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 Unix and Linux 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 11:16 PM.