Re: querying multiple params
Maurice Mengel <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
Hi Petr,
thanks for the quick answer!
It is not that I didn't read these sentences, but I don't quite know what to
do with it. I tried a lot of other queries a long the way today and they
worked as expected, e.g.
//mpx:sammlungsobjekt[mpx:andereNr[@art = 'ID' and . = '$id'] and
mpx:andereNr[@art ='DAT-Nr.' and . ]]
Only the full one doesn't work:
//mpx:sammlungsobjekt[mpx:andereNr[@art = 'ID' and . = '$id'] and
mpx:andereNr[@art ='DAT-Nr.' and = '$tape_no']]
That means only when I add the second variable, it doesn't work. That's why
I assumed, I don't need to take the namespace issue into consideration.
Anyways, it would be somewhat counter intuitive if the 2nd criterion breaks
the namespace. At least, this is how it looks for me at the moment.
I tried of course what you suggest. But I don't really get it either. I
cannot find any example on the web easily. Special thanks therefore for the
faq. I forgot about it. I am not sure I understand XPathContext. Anyways,
my $xpc = XML::LibXML::XPathContext->new;
$xpc->registerNs('mpx', 'http://www.mpx.org/mpx');
my $xpath ="//mpx:sammlungsobjekt[mpx:andereNr[\@art = 'ID' and . =
'$id'] and mpx:andereNr[\@art ='DAT-Nr.' and . = '$tape_no']]";
my @nodes = $xpc->findnodes($xpath, $root);
gives me exactly the same result (with and without the 2nd variable).
Are you sure it is the namespace? Seems hard to believe...
I would assume it is the difference between simulated xpath 1 and xpath2 or
something fishy in the query...
anyways, thanks a lot
Maurice
On Fri, Jul 24, 2009 at 12:45 AM, Petr Pajas <[email protected]> wrote:
> 2009/7/24 Maurice Mengel <[email protected]>:
> > Hi List,
> >
> > i don't know where to look anymore. Hope you know more
> >
> > With libxml, i try to pass this query and I get no results:
> >
> > my $xpath ="//mpx:sammlungsobjekt[mpx:andereNr[\@art = 'ID' and .
> =
> > '$id'] and mpx:andereNr[\@art ='DAT-Nr.' and . = '$tape_no']]";
> > my @nodes = $root->findnodes($xpath);
> >
> >
> > I try the same query in oXygen (xpath1) and I get the results that I am
> > looking for.
> >
> > Any suggestions for me?
>
> Yes, read this:
>
> http://perl-xml.sourceforge.net/faq/#namespaces_xpath
>
> or read carefully the documentation on the findnodes method at
>
> http://search.cpan.org/dist/XML-LibXML/lib/XML/LibXML/Node.pod
>
> (pay special attention to the NOTE ON NAMESPACES AND XPATH)
>
> -- Petr
>
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs