sub printNode { my ($theNode) = @_; my $thisType = $theNode->getNodeType; my $nodeList = $theNode->getChildNodes; my $name = $theNode->getNodeName; my $attLength; my $length = $nodeList->getLength; my $attList = $theNode->getAttributes; if( $attList ){ $attLength = $attList->getLength }; #print $sep x ($depth), "-NodeName: '$name' (type $thisType, $length children)\n"; $depth++; for(my $i=0; $i<$length; $i++) { my $node = $nodeList->item($i); my $theType =$node->getNodeType; my $j=$i+1; if ($theType == ELEMENT_NODE ) { #print $sep x ($depth), "[$j]Element Node: '", $node->getTagName, "'\n"; #Recursive call to itself printNode( $node ); } elsif ($theType == TEXT_NODE ) { my $temp = $node->getData; #Sub out the tabs and newlines with text equivalents $temp =~ s/\n/\\n/g; $temp =~ s/\t/\\t/g; unless ($name eq "provinces") { print $sep x ($depth), $name.qq~="~.$temp.qq~"\n~; } } else { print $sep x ($depth), "[$j]UNKNOWN Node: ", $node->getNodeName, "\n"; } } $depth--; }