jim_neophyte has asked for the wisdom of the Perl Monks concerning the following question:
what is the proper to way to get the "id" attribute's value? what is the proper way to get the string "political" and the string "Thomas Jefferson" returned? what i am trying:<quotelist> <quotation style="wise" id="q4"> <source> Juan Ramon Jiminez </source> <quotation id="q5" style="political"> <source> Thomas Jefferson </source> </quotation> </quotelist>
i thought i would get "Thomas Jefferson" with this. not finding enough xpath examples to know if i am even using xpath correctly. i have both "XML in a Nutshell" and "Learning XML". thanks in advance for advice and pointers.use warnings; use strict; use Data::Dumper; use XML::DOM::Lite qw( Parser XPath ); my $doc = Parser->parseFile( '/rshome/jaw2/xml/practice.xml' ); my $result1 = XPath->evaluate( 'quotelist/quotation[@id="q5"/@style', +$doc ); print Dumper $result1; my $result2 = XPath->evaluate( '/quotelist/quotation[id="q5"]/source/t +ext()', $doc ); print Dumper $result2;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: trying to use XML::DOM::Lite
by whereiskurt (Friar) on Jul 03, 2007 at 01:42 UTC | |
by jim_neophyte (Sexton) on Jul 06, 2007 at 15:01 UTC | |
by jim_neophyte (Sexton) on Jul 09, 2007 at 16:01 UTC |