Skip Menu |

This queue is for tickets about the XML-LibXML CPAN distribution.

Report information
The Basics
Id: 39796
Status: resolved
Priority: 0/
Queue: XML-LibXML

People
Owner: Nobody in particular
Requestors: JETEVE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.66
Fixed in: (no value)



Subject: Can we have a binding for xmlPatternMatch function ?
Hi all, It'd be great to have a perl binding to the function : Function: xmlPatternMatch int xmlPatternMatch (xmlPatternPtr comp, xmlNodePtr node) From pattern.h (in LibXML ). Used in conjunction with copyCurrentNode (deep), it would unlock the possibility of implementing a pure streaming parsing of sub nodes of interest in the document. (For the moment, the solution of having them all at the end of the parsing doesn't please me that much because my documents are huge). I tried XML::Filter::DOMFilter::LibXML which is supposed to do exactly that, but I was disappointed with the results. Kind regards, Jerome.
Hi, in the SVN version it is already implemented. The synopsis for pattern support look like this: use XML::LibXML; my $pattern = new XML::LibXML::Pattern('/x:html/x:body//x:div', { 'x' => 'http://www.w3.org/1999/xhtml' }); # test a match on a XML::LibXML::Node $node if ($pattern->matchesNode($node)) { ... } # or on a XML::LibXML::Reader if ($reader->matchesPattern($pattern)) { ... } # or skip reading all nodes that do not match print $reader->nodePath while $reader->nextPatternMatch($pattern); $pattern = XML::LibXML::Pattern->new( pattern, { prefix => namespace_URI, ... }); $bool = $pattern->matchesNode($node);