this code:<?xml version="1.0"?> <quotelist> <quotation style="wise" id="q1"> <text>Expect nothing; be ready for anything.</text> <source>Samuri Chant</source> </quotation> <quotation style="political" id="q2"> <text>If one morning I walked on top of the water across the Potom +ac River, the headline that afternoon would read "President Can't Swim."</text> <source>Lyndon B. Johnson</source> </quotation> <quotation style="silly" id="q3"> <?human laugh?> <text>What if the hokey-pokey IS what it's all about?</text> </quotation> <quotation style="wise" id="q4"> <text>If they give you ruled paper, write the other way.</text> <source>Juan Ramon Jiminez</source> </quotation> <!-- the checkbook is mighter than the sword? --> <quotation style="political" id="q5"> <text>Banking establishments are more dangerous than standing armies.</text> <source>Thomas Jefferson</source> </quotation> </quotelist>
produces: $VAR1 = 'Thomas Jefferson';use warnings; use strict; use Data::Dumper; use XML::LibXML; my $parser = XML::LibXML->new; my $doc = $parser->parse_file( 'practice.xml' ); my $xpath = '/quotelist/quotation[@id="q5"]/source/text()'; my $result = $doc->find( $xpath ); print Dumper $result->string_value; exit 0;
will go back to XML::DOM::Lite when i have more time. for the time being concentrating on XML::LibXML which because we have seven unixen and ms-windows to compile for, creates new and improved headaches. :)
In reply to Re^2: trying to use XML::DOM::Lite
by jim_neophyte
in thread trying to use XML::DOM::Lite
by jim_neophyte
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |