toadi has asked for the wisdom of the Perl Monks concerning the following question:
My output and errors:use strict; use XML::LibXML; my $dom = XML::LibXML->new->parse_file('XMLS/PXMLStatusMessage.xml'); my $root = $dom->getDocumentElement(); my @node = $root->findnodes("//partnerContact/companyName"); my $all; foreach (@node) { &traverse($_, \$all); } print "DEBUG:\n".$all; sub traverse { my ($node, $all) = @_; if ($node->getType == XML_ELEMENT_NODE) { $$all .= "<", $node->getName, ">\n"; print "<", $node->getName, ">\n"; foreach my $child ($node->childNodes()) { &traverse($child,$all); } $$all .= "</", $node->getName, ">\n"; print "</", $node->getName, ">\n"; } elsif ($node->getType() == XML_TEXT_NODE) { $$all .= $node->getData."\n"; print $node->getData."\n"; } }
Well I'm just trying to figure out why the prints work and my catching of the output in a variable doesn't?? Am I missing something about references?Useless use of a constant in void context at ./myparse.pl line 31. Useless use of a constant in void context at ./myparse.pl line 36. <companyName> Planet Internet </companyName> DEBUG: <Planet Internet
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Recursion problem
by ChemBoy (Priest) on Jul 27, 2001 at 17:41 UTC | |
|
Re: Recursion problem
by clemburg (Curate) on Jul 27, 2001 at 16:56 UTC |