[libxml++] Re: Formatting problem



Bastian_Pfennigschmidt/CODESCO/DE codesco com a écrit :


Hello Christophe,


Hi Bastian,

<snip>

Why the parser doesn't remove the formatting linebreaks and spaces, if I parse it again? If I call write_to_xxx I don't want to get a formatted output, even if the input was formatted.
Is there any way to get a unformatted output if the input was formatted?


Removing formatting linebreaks and spaces at parsing time imply a decision on wether or not a whitespace is significant (See http://www.xmlsoft.org/html/libxml-parser.html#xmlKeepBlanksDefault for more information about it).

However if you are able to decide if a whitespace is significant or not, then you can walk your dom tree and remove them. This shouldn't be hard to implement : you just have to remove all content nodes that are white space (see bool ContentNode::is_white_space <http://libxmlplusplus.sourceforge.net/reference/html/classxmlpp_1_1ContentNode.html#a4> () const).

There is another possibility, which is to change the behavior of libxml++ regarding whitespaces by changing KeepBlanks::Default to false. But this solution will be heavy to maintain for you. Eventually we can think about a little modification in the next API to allow a dynamic change of this setting, but we'll have to convince Murray :-).


Thanks for helping


You're welcome,

Christophe





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