Thank you to everyone who responded.  This should help me focus my
research to just a few XML modules in getting to a good solution for my
needs.

Thanks Chris for the links so that I can review some basic XML concepts
& issues.

Curtis

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jenda
Krynicky
Sent: Tuesday, November 11, 2008 7:08 AM
To: [email protected]
Subject: Re: Working with XML in Perl

From: "Curtis Leach" <[EMAIL PROTECTED]>
> I'm using a Perl 5.8.8 build on a Windows Server platform and I need 
> to work with XML files.
> 
> Is there a preferred module for use when working with XML in Perl?  
> I'm new to XML & I'm just looking for directions to XML modules to 
> look at so I don't waste too much time going down the wrong path while

> wading through all the available XML modules on CPAN.

Have a look at XML::Twig. Especially for huge documents it's much better
than the XML::DOM or XML::LibXML (in tree mode) since it doesn't require
that you load the whole file into memory at one time.
 
> I have a few example programs using XML::Simple (v2.14)for parsing out

> a couple of config values from some small XML files and returning them

> to the caller, but I'm going to need to programmatically edit more 
> complex XML files that are considerably larger & save the results.  
> With the potential of the files being edited being huge.  But maybe 
> 10,000 to 15,000 data points to update being average.
> 
> I'm going to see multiple entries such as:
> 
> <tag22 rt="abcd" seg="22" opt="xyz" /> ....
> <tag22 rt="masd" seg="14" opt="zxy" />
> 
> So I'll load the XML file into memory, validate it's well formed XML, 
> and then locate every occurrence of tag22 to update it's optional
"seg"
> attribute.  Making sure I only update a specific tag22 one time!  Once

> I've updated them all, I'll write the updated XML document back to
disk.

Why do you want to load it all into memory and validate before you start
to update it?

You can process the file as you parse the tags and create the updated
file as you go. And if you find out it was not well-formed you can
delete the new file and report the error. That will be much much quicker
and use much less memory.

Have a look at XML::Twig and XML::Rules for things like that.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes
to wine, women and song, wizards are allowed to get drunk and croon as
much as they like.
        -- Terry Pratchett in Sourcery

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to