http://www.perlmonks.org?node_id=1042553


in reply to Re: XML parsing and Lists
in thread XML parsing and Lists

Thanks for responding.I was not aware of XPathContext module in LibXML. I was trying to use XML::XPath directly and got into an infinite loop of installation issues which I could not get past.

I will try using this approach. Basically, I have to create a array of nodes for the path:

$parser = XML::LibXML->new; $dom = $parser->parse_file($file); $root = $dom->getDocumentElement; $dom->setDocumentElement($root); my $xc = XML::LibXML::XPathContext->new($file); my @nodes=$xc->findnodes('//Article//Part//Sect//H5[ contains(.,"I +nclude")]',$dom); if (@nodes) { $count = $xc->findvalue('count(//Article//Part//Sect//LI)',$dom); print $count; }

Am I on the right track? Anything I'm missing?

Thanks much.