i have since given up on XML::DOM::Lite. here is my complete xml document copied out of "Learning XML":
<?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>
this code:
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;
produces: $VAR1 = 'Thomas Jefferson';

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.