XML Whitespace
in Xml 1.0
- XML considers four characters to be whitespace: the carriage return (\r or ch(13)), the linefeed (\n or ch(10)), the tab(\t), and the spacebar (’ ‘).
- W3C: No white space before PI
- whitespace make different between XML document
- > eg: when you want to get first element Child of x: the statement: x.nodeChilds[0] and nodeList[0].firstChild may be a text node instead of an element node
- IE will not treat empty whitespace while other browsers do
- use xml:space attribute to identify a portion of document where whitespace is necessary
<poem xml:space=”default”> (there a two value: default & preserve)
- in MS XML DOM - xmlDoc.preserveWhiteSpace= true; xmlDoc.load(url); // to preserve whiteSpace
Solution:
- use if while parse to identify exactly what you want
- use normalize to join spaces
- W3C XSLT: <xsl:strip-space elements=”*”/> or <xsl:preserve-space elements=”*”/>
Ref
http://msdn.microsoft.com/en-us/library/ms256097.aspx
http://www.oracle.com/technology/pub/articles/wang-whitespace.html