logo       

Re: XML parsing in P6: msg#00008

lang.perl.perl6.compiler

Subject: Re: XML parsing in P6

On Mon, Mar 13, 2006 at 00:27:32 +0530, Premshree Pillai wrote:
> Hello,
>
> [not sure if this belongs to this list; if not, apologies, and maybe
> point me to the right list]

#perl6 on freenode might be a better choice - much more people are
active.

> New to P6. Just compiled Pugs on OS X, so am just playing around. I
> was wondering if there's any XML parsing module available in Pugs. I
> saw an XML-SAX in misc/, but was wondering how to use it -- or of it
> can be used in the first place.

That's a port of the Perl 5 XML::SAX
(http://search.cpan.org/perldoc?XML::SAX) which is basically a
parser factory...

Unfortunately it doesn't seem like anyone actuallu wrote an XML::SAX
driver in perl 6 yet.

> If there isn't one, can I use a P5 module in P6? I remember seeing
> something like "use P5ModuleName--per5". Is that the current state of
> the art?

Yes: you can do something like

use perl5:XML::SAX;

in Perl 6 code, and get the [reasonably] sane API that XML::SAX
offers, along with the *HUGE* array of drivers.

Essentialy XML::SAX wants you to inherit from some handler base
class, and then handle events like 'start_tag', etc.

Some more "fun" XML modules exist on on the CPAN, which provide more
"treeish" APIs than event parser APIs.

Ciao!

--
() Yuval Kogman <nothingmuch@xxxxxxxxxxxx> 0xEBD27418 perl hacker &
/\ kung foo master: /me climbs a brick wall with his fingers: neeyah!

Attachment: pgpFRxbmothzp.pgp
Description: PGP signature

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise