How to nodetype as "ELEMENT_NODE" using xml::libxml in perl?

Hi,

I am using xml::libxml.

Here is the code.

my $parser = XML::LibXML->new();
my $xmldoc = $parser->parse_file ("file.xml") || die("Could not parse config xml file\n");
my $root = $xmldoc->getDocumentElement()|| die("Could not get Document Element \n");
$id="121313131"; # For example
proceed($root,$id);
sub proceed {
my($node,$id)= @_;
#$node->nodeType is returning "1"
if ($node->nodeType == ELEMENT_NODE) 
	{
		print "\n -----------------\n";
		#get all the child nodes
	}
		
}

My question is the control is not entering in if loop.

How to get the ELEMENT_NODE and check for the condition weather is it ELEMENT_NODE or node and get all the children in perl only?

#cat file.xml
<JUNKS>
	<JUNK>
		<NAME>AAA</NAME>
		<AGE>12</AGE>
	<JUNK>
		<ADDR>Q1WQW</ADDR>
		<NUM>1212</NUM>
	</JUNK>
  </JUNK>
</JUNKS>

Output:
<JUNKS>
	<JUNK>
	 <NAME>AAA</NAME>
	 <AGE>12</AGE>
	 <ADDR>Q1WQW</ADDR>
	 <NUM>1212</NUM>
</JUNK>
</JUNKS>

This is just a sample file.

How can i get ELEMENT_NODE and all its children using xml::libxml in perl?

Regards
Vanitha

You have to interate through your JUNKS elements and for ever JUNK child element, pull it's child elements and print them if present, and print a divider. XML::LibXML - An XML::Parser Alternative

see below link

http://search.cpan.org/~pajas/XML-LibXML-1.70/LibXML.pod#EXPORTS
and also view XML::SimpleObject  module.

BR