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

RE: PERL and XML Parser

Thread Previous | Thread Next
From:
Hanson, Robert
Date:
February 1, 2002 07:26
Subject:
RE: PERL and XML Parser
Message ID:
11A304418ECBAB498FBF10ABCEA5E499D1CDCF@hq2kax1.nj.aptegrity.com
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;

$rax->openfile('killme.xml');
$rax->setRecord('albums');

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.

Rob




-----Original Message-----
From: P0R0NG [mailto:p0r0ng@yahoo.com]
Sent: Friday, February 01, 2002 8:10 AM
To: beginners@perl.org
Subject: Re: PERL and XML Parser


On Fri, 1 Feb 2002 21:04:54 +0800
P0R0NG <p0r0ng@yahoo.com> 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.

percy

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About