XML tag name content replacement

Hi,

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

Scenario is :

<abc_def>Value_some_content</abc_def>

Expected output :

<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.

awk -F'<' '/^</{sub("_",":",$2);}/>$/{sub("_",":",$NF);}1' OFS='<' xmlfile
1 Like
$ echo '<abc_def>Value_some_content</abc_def>' | sed 's,abc_def,abc:def,g'
<abc:def>Value_some_content</abc:def>

Thanks bipinajith..

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