Curtis Leach said:
> Is there a preferred module for use when working with XML in Perl?  

I use: 
XML::DOM;

If you have the full file that's probably the best one I've found. Although
you might consume massive amounts of memory depending on your file size (you
seemed to indicate they'd be big).

There are basically 2 ways to parse XML one is with a Tree structure with
something like XML::DOM, or with an event based parser (Usually SAX is
mentioned here).  Not sure much about the event based one, I've always used
DOM. There are many proponent of both types of processing but if you've got
the whole file it's pretty easy to implement what you want to do with DOM.

Curtis:
> 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.


#load and parse file into a variable
$parser = new XML::DOM::Parser;
$maindoc = $parser->parsefile($file);
#get a perl list of all tags named tag22
foreach $node ($mainDoc->getElementsByTagName('tag22',1))
{   $node->setAttribute('seq','newval'); }

#save it back.
.... not sure how to do this... honestly haven't done it before.


GL, and hope that helps.

-Wayne Simmons


--
Software Engineer
InterSystems USA, Inc.
303-858-1000 
 



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

Reply via email to