Hi guys,
I want to traverse a XML file and would like to print value of every node and the name of node. I tried this with XML:

OM, XML::Twig and XML:

arser using event handle and able to achive this XMl::Twig and XML:

arser but with XML:

OM it doesnt display me the required results.
Please see the script/xml/results below.
use XML:

OM;
my $infile = shift;
my $dom_parser = new XML:

OM:

arser; # create a parser object
my $doc = $dom_parser->parsefile( $infile ); # make it parse a file
my $paras = $doc->getElementsByTagName( "note" );
for( my $i = 0; $i < $paras->getLength; $i++ ) {
my $para = $paras->item( $i );
my
@children = $para->getChildNodes;
foreach my $node (
@children ) {
if( $node->getNodeType eq TEXT_NODE ){
my $tmp= $node->getData;
my $tmp= $node->getNodeValue;
my $val = $node->getNodeName;
print "\n Text:: $val :: $tmp";
}elsif ( $node->getNodeType eq ELEMENT_NODE ){
my $tag= $node->getNodeName;
my $val=$node->getNodeValue;
print "\n Element : $tag :: $val";
}
}
}
test xml file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mail>
<note time="12:03:46">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
</mail>
result ::
C:\>perl test.pl test.xml
Text:: #text ::
Element : to ::
Text:: #text ::
Element : from ::
Text:: #text ::
Element : heading ::
Text:: #text ::
Element : body ::
Text:: #text ::
C:\>
Why I the value of text field is empty.
I tried couple of ways on this .. getValue,getNodeValue,getData or print to string etc but nothing helps ?
Please help me to solve this mystery