You can't really strictly "append" to a well-formed XML without breaking the syntax. You need the properly closed top level element at the very least, in addition to whatever nesting may be going on. An ugly solution would be to chop off the end of whatever file you're dealing with and then recreate it (assuming you know what the end of the file looks like). A better solution would be to read the previous file and generate a new XML document. Probably the best solution (assuming the file is big enough or the operation intricate enough to merit it) would be to write some wrapper functions for your specific XML scheme which will ensure that the document syntax is what is expected, and then insert the elements in the proper location (most likely using another module in place of or in addition to XML::Writer).
Steven Sim wrote: > Gurus; > > Sorry if this is not the proper forum. > > I've successfully written a Perl script to create a specific XML file. > > The problem comes when I attempt to run the script again and append > XML entries onto the XML file. > > Using XML::Writer, I am unable to perform a proper append. (The append > IO is successful but it breaks the XML syntax.) > > Could some guru here share the logic of appending data onto an > existing XML file using XML::Writer? > > (Using it to create a brand new XML file is easy. It's the appending > that is really giving me a headache). > > Warmest Regards > Steven Sim > > > > > > > Fujitsu Asia Pte. Ltd. > _____________________________________________________ > > This e-mail is confidential and may also be privileged. If you are not > the intended recipient, please notify us immediately. You should not > copy or use it for any purpose, nor disclose its contents to any other > person. > Opinions, conclusions and other information in this message that do > not relate to the official business of my firm shall be understood as > neither given nor endorsed by it. > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/