Subject: | findnodes errors out when looking for attribute or comment nodes |
The following code using XML::XPath works:
use XML::XPath;
print $_->getData . "\n" for XML::XPath->new(xml => '<root><element1
attribute="e1"/><element2 attribute="e2"/></root>')->findnodes('//@*');
It outputs the values of all attributes properly:
e1
e2
But the same code using XML::DOM::XPath fails:
use XML::DOM::XPath;
print $_->getData . "\n" for
XML::DOM::Parser->new->parse('<root><element1 attribute="e1"/><element2
attribute="e2"/></root>')->findnodes('//@*');
It generates the following error message:
axis axis_attribute not implemented [Can't use an undefined value as an
ARRAY reference at /usr/lib/perl5/site_perl/5.8.6/XML/XPath/Step.pm line
220.
]
The same happens applies to comment nodes:
use XML::XPath;
print $_->getData . "\n" for XML::XPath->new(xml =>
'<root><!--comment1--><!--comment2--></root>')->findnodes('//comment()');
outputs:
comment1
comment2
But:
use XML::DOM::XPath;
print $_->getData . "\n" for
XML::DOM::Parser->new->parse('<root><!--comment1--><!--comment2--></root>')->findnodes('//comment()');
generates the following error message:
axis axis_descendant not implemented [Can't locate object method
"isCommentNode" via package "XML::DOM::Element" at
/usr/lib/perl5/site_perl/5.8.6/XML/XPath/Step.pm line 401.
]
Please kindly look into this. Thanks a lot!!
Best regards,
Ben