Skip Menu |

This queue is for tickets about the XML-DOM-XPath CPAN distribution.

Report information
The Basics
Id: 8167
Status: resolved
Priority: 0/
Queue: XML-DOM-XPath

People
Owner: MIROD [...] cpan.org
Requestors: ben.hsing [...] oracle.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.05
Fixed in: 0.06



Subject: XML::DOM::Node::toString does not work at the document root level
The following simple piece of code does not work: -- CODE BEGINS -- use XML::DOM::XPath; $xml = XML::DOM::Parser->new->parse('<root>hello world</root>'); print $xml->toString; -- CODE ENDS -- This will produce the following error message: Can't locate object method "print" via package "XML::XPath" (perhaps you forgot to load "XML::XPath"?) at /usr/local/perl561/lib/site_perl/5.6.1/XML/DOM.pm line 3624. But the same code using XML::DOM works flawlessly: -- CODE BEGINS -- use XML::DOM; $xml = XML::DOM::Parser->new->parse('<root>hello world</root>'); print $xml->toString; -- CODE ENDS -- This will print the string "<root>hello world</root>" as intended. The workaround for me right now is to loop through the child nodes and print them one by one instead: -- CODE BEGINS -- use XML::DOM::XPath; $xml = XML::DOM::Parser->new->parse('<root>hello world</root>'); print $_->toString for $xml->getChildNodes; -- CODE ENDS -- And no error will occur. I love this hybrid DOM/XPath module but this bug can really be annoying at times. Unfortuntely I don't know enough about the XML::DOM and XML::XPath's internals to debug it myself. Hopefully somebody can help. By the way I'm running Perl 5.6.1 built for i686-linux, with XML-DOM-1.43, XML-XPath-1.13 and XML-DOM-XPath-0.05 installed. Thanks a lot!
[guest - Thu Oct 28 18:37:46 2004]: Show quoted text
> The following simple piece of code does not work: > > -- CODE BEGINS -- > use XML::DOM::XPath; > $xml = XML::DOM::Parser->new->parse('<root>hello world</root>'); > print $xml->toString; > -- CODE ENDS -- > > This will produce the following error message: > Can't locate object method "print" via package "XML::XPath" (perhaps > you forgot to load "XML::XPath"?) at > /usr/local/perl561/lib/site_perl/5.6.1/XML/DOM.pm line 3624.
Indeed it looks like a bug. I'll have a look at it tonight and will answer hopefully tomorrow. Thanks __ Mirod