develooper Front page | perl.beginners | Postings from February 2002

RE: PERL and XML Parser

Thread Previous | Thread Next
Hanson, Robert
February 1, 2002 07:26
RE: PERL and XML Parser
Message ID:
There are tons of XML modules, many of which make that sort of thing easy...
but it depends on exactly what you want to do.  Here are some snippets:

use XML::EasyOBJ;

my $obj = new XML::EasyOBJ('killme.xml');

foreach ( $obj->albums ) {
	print $_->owner->getString . "\n";

-- OR --

use XML::RAX;

my $rax = new XML::RAX;


while ( my $rec = $rax->readRecord ) {
	print $rec->getField('owner') . "\n";

....And there are *LOTS* more.  It all depends on what you need to do.

BTW - The current version of XML::EasyOBJ on CPAN is a bit old.  I have a
newer version that includes read and write capabilities but I haven't
written up the new docs for it yet.  I can send it if you wanted.


-----Original Message-----
From: P0R0NG []
Sent: Friday, February 01, 2002 8:10 AM
Subject: Re: PERL and XML Parser

On Fri, 1 Feb 2002 21:04:54 +0800
P0R0NG <> wrote:

|how can i get the PCDATA for the element "owner"? i want to get just 
|the "owner" elements and the content of the "owner."
|i've created a code that will trap for the start and end tags of 
|the element "owner" as well as the handlers for the characters 
|that were part of the markup but no particular handlers.

i forgot, my code was getting all the contents with no particular handlers.
(ie contents of "rock", "reggae", "owner" elements were trapped. all i want 
is the content of the "owner" elements.

thanks again.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About