|There's more than one way to do things|
XML::LibXML - How to extract an element including the elements within?by TravelAddict (Acolyte)
|on May 09, 2019 at 19:10 UTC||Need Help??|
TravelAddict has asked for the wisdom of the Perl Monks concerning the following question: ⭐
I'm trying to extract elements from nodes in XML using XML::LibXML, and I need to extract the elements that could be embedded within that node.
For example, I have this XML string: <doc><text>From mobile, <ph1 i="1" type="33" x="1"/>dial<ph2 i="1"/> this number:</text></doc>
What I need as a result is this: From mobile, <ph1 i="1" type="33" x="1"/>dial<ph2 i="1"/> this number:, but I cannot extract the elements embedded (<ph1 i="1" type="33" x="1"/> and <ph2 i="1"/>), they disappear no matter what I try.
This is the sample code to reproduce the issue:
This is what I get when I run this code:
It looks like "to_literal", "findvalue" and "textContent" take out the embedded placeholders, but I want to keep them in.
Is there any way to get what I need with a simple method?
Thanks very much in advance!