in reply to Re: trying to use XML::DOM::Lite
in thread trying to use XML::DOM::Lite

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. :)

Replies are listed 'Best First'.
Re^3: trying to use XML::DOM::Lite
by jim_neophyte (Sexton) on Jul 09, 2007 at 16:01 UTC

    never did get XML::DOM::Lite to do what i wanted, but that could easily be my misunderstanding the doc. wanted to share my experiences with LIB::LibXML.

    i was able to compile, test, install for axp, ibm, sgi, hp (pa-risc), rhe3(linux), and sun 5.8.

    special notes:
    * check the generated makefile very carefully for correct include path and libary path. neither of the two methods for spcifying the libxml2 work correctly on all platforms. (putting path to xml2-config in your PATH nor XMLPREFIX=... to Makefile.PL). will try to figure that out and report to authors.
    * on hp11 if one sees: /usr/lib/pa20_64/dld.sl: '/lib/pa20_64/libpthread.1' contains a static TLS reference to '__thread_specific_seg' defined in a dynamically loaded library '/lib/pa20_64/libpthread.1'. Use +tls=dynamic to re-compile '/lib/pa20_64/libpthread.1'. then set and export LD_PRELOAD=/lib/pa20_64/libpthread.1
    * on linux, be sure to ensure that you are not linking with native lbxml2

    meanwhile my little test program:
    use warnings; use strict; use Data::Dumper; use XML::LibXML; my $parser = XML::LibXML->new; my $doc = $parser->parse_file( 'practice.xml' ); my $xpath1 = '/quotelist/quotation[source = "Thomas Jefferson"]/@style +'; my $result1 = $doc->find( $xpath1 ); print Dumper $result1->string_value; my $xpath2 = '/quotelist/quotation[@id="q5"]/source/text()'; my $result2 = $doc->find( $xpath2 ); print Dumper $result2->string_value; exit 0;
    produces:
    $VAR1 = 'political'; $VAR1 = 'Thomas Jefferson';
    yea! hth someone.