Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Using XPath in libXML

by Corion (Pope)
on Feb 09, 2009 at 15:29 UTC ( #742461=note: print w/replies, xml ) Need Help??

in reply to Using XPath in libXML

You don't show us your code, you don't show us your data, and you don't show us the error message you get. My crytal ball claims that maybe you're just running double quoted strings where you should be using single quoted strings. See perlop about how these differ - one interpolates and the other doesn't.

For the record, I had no problems using the XPath implementation of XML::LibXML. Accessing an attribute of a root node (or rather, getting the node containing it) would be done using


as the XPath expression. A likely sample could be:

... my $query = '/root@foo'; my @nodes = $document->find_nodes($query);

Replies are listed 'Best First'.
Re^2: Using XPath in libXML
by ramrod (Curate) on Feb 09, 2009 at 17:46 UTC
    Ah, the quotes mix up. I didn't consider that. The criteria I was using to access some of the nodes was in the form:

    my $query = "//property[color = 'Blue']/OtherProperty/text()";

    This threw me off. I switched to using the single (literal) quotes and this has helped quite a bit. However I am still curious if there are other "/text()" style path calls. (Just in case there are better ways of doing things.)

    Thanks for you help.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://742461]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2018-06-23 20:08 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.