Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with getChildNodes() command

Status
Not open for further replies.

shlomyb

Programmer
Nov 14, 2006
32
IL
I use the following xml:
<?xml version="1.0"?>
<me>
<name>Joe Cool </name>
<age>24</age>
<sex>male</sex>
</me>

my Ques.

Why when I use the following code I get 7 and not 3 , if it is a recursive command , why 7 and not 6 ???
print $children->getLength;


The full script :

#!/usr/bin/perl
use XML::DOM;
$xp = new XML::DOM::parser();
$doc = $xp->parsefile("in.xml");
$root = $doc->getDocumentElement();
my $children = $root->getChildNodes();
print $children->getLength;
 
The Reason is in the XML file.
When I tried to use a flatted xml (with no new lines only one long line) file it seems to work.

Any suggestions . why ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top