Search code examples
xmlperlxml-twig

How to get raw XML code from XML::Twig element


I'm a super-beginner with XML::Twig. I have an XML::Twig element with some HTML code in it. I can do

$element->text

And get the text from it, but it strips out all the HTML tags, making them children. Is there anyway to just get the full code from the element? I'm even ok if it's encoded with html entities.


Solution

  • $elt->sprint or $elt->inner_xml depending on whether you want the element start and end tags to be included (sprint) or not (inner_xml)