From: Christophe de V. <cde...@ne...> - 2004-01-13 12:02:11
|
Bastian_Pfennigschmidt/CODESCO/DE...@co... a =E9crit : > > Hello Christophe, > Hi Bastian, <snip> > Why the parser doesn't remove the formatting linebreaks and spaces, if=20 > I parse it again? > If I call write_to_xxx I don't want to get a formatted output, even if=20 > 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=20 decision on wether or not a whitespace is significant (See=20 http://www.xmlsoft.org/html/libxml-parser.html#xmlKeepBlanksDefault for=20 more information about it). However if you are able to decide if a whitespace is significant or not,=20 then you can walk your dom tree and remove them. This shouldn't be hard=20 to implement : you just have to remove all content nodes that are white=20 space (see bool ContentNode::is_white_space=20 <http://libxmlplusplus.sourceforge.net/reference/html/classxmlpp_1_1Conte= ntNode.html#a4>=20 () const). There is another possibility, which is to change the behavior of=20 libxml++ regarding whitespaces by changing KeepBlanks::Default to false.=20 But this solution will be heavy to maintain for you. Eventually we can think about a little modification in the next API to=20 allow a dynamic change of this setting, but we'll have to convince=20 Murray :-). > > Thanks for helping You're welcome, Christophe |