Subject: | XML root element gets empty |
Hello.
Returning a XML::Elemental::Element (example, the root node) on a sub, may result on an
empty element.
On the attached example, I get a XML, parse it and return the root node.
The result is:
ZeMacBook:Desktop david$ ./test_xml_elemental.pl
$VAR1 = bless( {}, 'XML::Elemental::Element' );
When we uncomment the line #11 the script returns the (my) expected output, the dump of
parsed XML.
Is this a bug? I started to get this behavior when I upgraded from 2.0 to 2.11.
Thank you.
Subject: | test_xml_elemental.pl |
#!/usr/bin/perl
use XML::Elemental;
use LWP::Simple;
sub getXMLRootNode {
my ($url) = @_;
my $doc = getXML($url);
my $root = $doc->root_element;
# $doc->{contents} = [];
return $root;
}
sub getXML {
my ($url) = @_;
my $p = XML::Elemental->parser({});
my $code = get($url);
my $doc = $p->parse_string($code);
return $doc;
}
my $xml = getXMLRootNode("http://services.sapo.pt/News/RSS");
use Data::Dumper;
print Dumper($xml);