Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Replacing an XPath node with the value of its contentby stylechief (Sexton) |
on Oct 21, 2013 at 19:09 UTC ( [id://1059156]=perlquestion: print w/replies, xml ) | Need Help?? |
stylechief has asked for the wisdom of the Perl Monks concerning the following question: Greetings Honorable Monks, I need to replace certain <tm> elements in an XML document with the value of the <tm> element. That is, I need to eliminate the element but retain its content in-place. For example, If I find: <tm tmclass="ibm" tmowner="IBM Corporation" tmtype="reg" trademark="AIX">AIX</tm>; I need to replace the entire <tm>...</tm> element with the text AIX.I am using XML::LibXML to detect the @tmowner, and trigger the above function. For example:
I have not had any luck with the replaceNode or replaceChild methods for this purpose. I know I could do this with regexps, but that might get messy with all of the preformatting necessary to manage multiple trademarks on one line. Tips and ideas are appreciated. Thanks for your time.
Back to
Seekers of Perl Wisdom
|
|