Re: [xml] xmlDocDumpFormatMemory problem?

Hi there,

xmlDocDumpFormatMemory(xmlDoc, &buf, &size, 1);

The data both of them send out looks as following:
<?xml version="1.0"?>
<test><a>data</a>hello world</test>

I assume that you have expected something like:

  <?xml version="1.0"?>
    hello world

right? All novices who use XML for trivial purposes expect such behaviour.
Forget it. I hope it is clear that the document I displayed here is not the
same as the one you displayed. My document's text nodes have additional
characters, namely spaces and newlines. These are not the part of the data,
but have been introduced by the indenting engine. Unfortunately, exactly
that information is missing in the resulting document--one cannot tell which
of these characters are data and which are just a formatting. When one
parses my document back, one gets a different DOM than was the original.

There is no way to make a difference between the whitespace and the
ignorable whitespace in text nodes. All you can do is guess, and whenever
the software guesses, it guesses wrong. For that reason, no formatting is
performed on nodes which contain text children.

I have tested version 2.4.21 on RedHat linux and also the windows versions
2.4.21 and 2.4.22 posted by Igor Zlatkovic on his web site. They behaved

That is good, they should behave the same.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]