Jenda Krynicky wrote:
> 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?
>
>   
If you're dealing with long enough XML files that recreating them isn't
efficient enough for your needs, then your primary source of information
shouldn't be this mailing list.

> The requirement of a root tag in XML is ... yet another lovely 
> misfeature of the format.
>   
XML apparently just isn't for you.  The closing root tag, if nothing
else, ensures that the document is whole and simplifies the parsing and
data format integrity which are large concerns of XML.  If the structure
of the format seems counter-intuitive to what you're doing then use
something else and optionally export XML for features you may be
interested in.  It doesn't fit everywhere.

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


Reply via email to