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

Re: [xml] Problem with XML output formatting



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

	Thank you very much for your excellent answer, Gait! That is the
information I needed.

	Best regards,
	Petyo

Gait Boxman wrote:
> Petyo,
> 
> for starters, I assume you switched the close tags for options and
> general in your example, otherwise it's not even XML.
> the formatting of the xml document is done through text. The general
> node actually contains:
> 
> a text node ( "<0d>       " )
> the value1 element node
> a text node ( "<0d>       " )
> the value2 element node
> a text node ( "<0d>       " )
> the value3 element node
> a text node ( "<0d>   " )
> 
> 
> (don't punish me for the exact number of spaces, it's just an indication).
> 
> When you remove the value2 element node, you end up with:
> a text node ( "<0d>       " )
> the value1 element node
> a text node ( "<0d>       " )
> a text node ( "<0d>       " )
> the value3 element node
> a text node ( "<0d>   " )
> 
> so that's why you get the (not really) empty line. to get rid of the
> empty line, you'll have to remove the node after the value2 node as well
> 
> when you then add the new value3 node in the end, you get:
> 
> a text node ( "<0d>       " )
> the value1 element node
> a text node ( "<0d>       " )
> a text node ( "<0d>       " )
> the value3 element node
> a text node ( "<0d>   " )
> the other value3 element node
> 
> and yes, when printed, the new node is placed right before the closing
> tag, after the text node that takes care of the indent..
> You'll have to handle the indentation yourself by handling the text
> nodes in code.
> Hint: drop any text nodes consisting of just whitespace after loading,
> and use an algorithm based on the depth of the node to add the
> indentation and line feeds just before printing.
> 
> 
> 
> 
> --Gait.
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDN68VH/3eKQaFKT0RAsvBAJ9Ny8IeTPj41QRHv/844ji/A5kJ2gCgsScs
87HoWaylQUV1n3ced1sqd4k=
=beOu
-----END PGP SIGNATURE-----



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