On 2 Oct 2007 at 10:54, Matthew Whipple wrote:
> 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).  

If you only have to bend backwards because the bright omnipotent 
creators of the XML standard thought it would be fun to force you to 
and the whole end-of-the-file that you need to chop off is a 
"</roottag>" then it's actually the best solution. No matter what 
would the XML purists love you believe.

> A better solution would be to read the previous
> file and generate a new XML document.

Which may be fine for small enough files, but is simply crazy for 
anything longer. Parse and rewrite something to insert something in 
the middle is something that can't be helped, but reparsing and 
recreating everything for APPEND?

The requirement of a root tag in XML is ... yet another lovely 
misfeature of the format.

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


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to