How whitespace (in data) is treated by XML Parser?
If this is a sample XML::
<root>
<tag1>data
data
data</tag1>
<tag2>
</tag2>
<tag3> </tag3>
</root>
This file is viewed differently in different browsers and XML viewer/editors,
some viewers display 1st <tag/>
element as <tag>data data data</tag>
some display as is,
What is the standard approach 开发者_StackOverflow社区for this white-space issue?
http://www.w3.org/TR/REC-xml/#sec-white-space
I believe that means it is optional but default behaviour should be to ignore non-significant whitespace.
Can you give me an example of an implementation which is showing the line breaks?
Conclusion
I validated the same XML against XSD which had defined <tag1/> <tag2/> ...
with enumeration values, (copied same value of the tags) when I altered the contents of <tag>
by adding/removing whitespace. The schema acknowledged mismatch which concludes that .. in general XML parser won't ingore the whitespace :)
But the transformation ignores whitespace, thats why the browsers ignore it too where as notepad is honest to display as is. ;)
Source/courtesy :: Nic Gibson's comment on jambox's answer
精彩评论