D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG] Perl question on XML::Parser



Does anyone here use XML::Parser in Perl?

I'm getting confused over the constant use of references to parse the tree and 
I can't get any data from a sample XML.

<?xml version="1.0"?>
<!DOCTYPE ISBNORG SYSTEM "http://www.isbn.org.uk/xml/isbnorg.dtd";>
<ISBNORG>
<RECORD>
<ISBN>1565922867</ISBN>
<AUTHOR>Ellen Siever, Stephen Spainhour &amp; Nathan Patwardhan.</AUTHOR>
<FULLTITLE>Perl in a nutshell : a desktop quick reference / Ellen Siever, 
Stephen Spainhour &amp; Nathan Patwardhan.</FULLTITLE>
<SHORTTITLE>Perl in a nutshell :</SHORTTITLE>
<EDITION></EDITION>
<PUBLISHER>O'Reilly,</PUBLISHER>
<DATE>c1999.</DATE>
<SUBJECT>Perl (Computer program language)</SUBJECT>
</RECORD>
</ISBNORG>

I can work it in PHP but I want to try Perl.

Could anyone help with an example script - I can't make sense of the POD 
output, it just talks of references and nodes, there's no example code for 
actually processing the nodes.

I've got this far:

use XML::Parser;
$p1 = new XML::Parser(Style => 'Tree');
$tree = $p1->parsefile('isbnorg.xml');
@a = @$tree;
print "Root: $a[0]\n";

output:
Root: ISBNORG



-- 

Neil Williams
=============
http://www.codehelp.co.uk/
http://www.dclug.org.uk/
http://www.isbn.org.uk/
http://sourceforge.net/projects/isbnsearch/

http://www.biglumber.com/x/web?qs=0x8801094A28BCB3E3

Attachment: pgp00043.pgp
Description: signature


Lynx friendly