dbonneville has asked for the wisdom of the Perl Monks concerning the following question:

Hello: I'm struggling mighty hard with XPath:

I have a script where this works:

my $nodeset = $xpath->find( '/Competitive/Item');

...and this works:

    my $nodeset = $xpath->find( '//*');

...and this works:

    my $nodeset = $xpath->find( '/Competitive/Item[position()<=200]');

...BUT this does NOT work:

    my $nodeset = $xpath->find( '/Competitive/Item[name()="Putnam"]');

...nor does this work either:

    my $nodeset = $xpath->find( '/Competitive/Item[starts-with(name()="Putnam")]');

I'm running Perl on Windows, with the latest ActiveState install.

Any ideas where to look or what to change? Why does one function (position) work and another function (name) not work for me?

Thanks!

Replies are listed 'Best First'.
Re: Help with XPath
by merlyn (Sage) on Aug 27, 2007 at 21:39 UTC
    Since there's no module called XPath, and it might make a difference, you'll need to narrow down which of the many XPath modules you're using. And, do you perhaps have troubles with namespaces here? I know XPath is really ugly about namespaces.
Re: Help with XPath
by pajout (Curate) on Aug 27, 2007 at 22:53 UTC
Re: Help with XPath
by gam3 (Curate) on Aug 27, 2007 at 20:19 UTC
    I think that you should include the xml you are working on (or a sub-set that has the same problem) and then someone might be able to debug it for you.
    -- gam3
    A picture is worth a thousand words, but takes 200K.