Reputation: 667
Ive searched the docs on cpan and google, cant seem to find an answer. Im using perl to read in an XML file. When I do the following code it complains that
XML::TinyXML::XmlGetChildNode: node is not of type XmlNodePtr at /usr/local/lib/perl/5.10.1/XML/TinyXML.pm line 485.
What do I have to do to my variable to make it an XmlNodePtr and use it correctly to call getChildNode()?
`
my $xml = XML::TinyXML->new();
$xml->loadFile("myfile");
my $node = $xml->getRootNode(1);
my $val = $node->value("context");
print "root Node value: $val\n"; prints "root Node value: context"
my $clen = $node->countChildren();
print "total children $clen\n"; prints "total children 115"
my $this_node = $xml->getChildNode($node, 0); <----error
`
Ive also tried what seems to be the proper solution (below) from the XML::TinyXML::Node doc which also says:
XML::TinyXML::XmlGetChildNode: node is not of type XmlNodePtr at /usr/local/lib/perl/5.10.1/XML/TinyXML.pm line 485.
`
my $ptr = XML::TinyXML::Node->new($node);
my $this_node = $xml->getChildNode($ptr, 0); <---- error
`
Upvotes: 0
Views: 186
Reputation: 2490
Try calling getChildNode
on $node
itself. Also, node indices probably start at 1, not 0.
my $this_node = $node->getChildNode(1);
Upvotes: 0