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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: XML parsing and Lists
by choroba (Cardinal) on Jul 05, 2013 at 00:50 UTC | |
by Anonymous Monk on Jul 05, 2013 at 01:30 UTC | |
by madbee (Acolyte) on Jul 05, 2013 at 04:28 UTC | |
by choroba (Cardinal) on Jul 05, 2013 at 08:41 UTC | |
by madbee (Acolyte) on Jul 05, 2013 at 01:56 UTC | |
by choroba (Cardinal) on Jul 05, 2013 at 02:00 UTC |
In Section
Seekers of Perl Wisdom