Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Perl and XPath.

by murugu (Curate)
on Jan 07, 2007 at 08:55 UTC ( #593380=note: print w/ replies, xml ) Need Help??


in reply to Perl and XPath.

getNodeValue method will give you the authors name.

#!/usr/bin/perl use warnings; use strict; my $a = do {local $/; <DATA>}; use XML::XPath; use XML::XPath::XMLParser; my $xp = XML::XPath->new(xml => $a); my $nodeset = $xp->find('//@author'); # find all authors foreach my $node ($nodeset->get_nodelist) { print $node->getNodeValue."\n\n"; }

Regards,
Murugesan Kandasamy
use perl for(;;);


Comment on Re: Perl and XPath.
Download Code
Re^2: Perl and XPath.
by Anonymous Monk on Aug 02, 2007 at 22:00 UTC
    Is it possible to use getNodeValue if you want to get values from multiple attributes at a single level in the tree. For example <id = "2" name = "Jim" Date = "Today" > So in my $node variable I have all of the values. How can I use getNodeValue to access them individually

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://593380]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2015-07-03 12:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls