Re: querying multiple params
Petr Pajas <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
2009/7/24 Maurice Mengel <[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... Sorry, answering emails late at night was not a good idea. You are right, if the namespaces were not registered, you would get an error. So hard to tell, post a sample XML file and the values of the interpolated variables. -- Petr _______________________________________________ Perl-XML mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs