Dan Goodspeed
Dan Goodspeed

Reputation: 3560

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.

Upvotes: 2

Views: 359

Answers (3)

Borodin
Borodin

Reputation: 126722

What you probably want is

print $element->toString;

Upvotes: 0

mirod
mirod

Reputation: 16161

$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)

Upvotes: 5

Sobrique
Sobrique

Reputation: 53488

Two options:

use Data::Dumper;
print Dumper \$element;

or:

$element -> print(); 

Upvotes: 1

Related Questions