Hi,
Is displaying these two ways the same and correct?
E.g.
< contents cpid="1" cpnm="1">< /contents >
and
< contents
cpid="1"
cpnm="1">
< /contents>
Hi,
Is displaying these two ways the same and correct?
E.g.
< contents cpid="1" cpnm="1">< /contents >
and
< contents
cpid="1"
cpnm="1">
< /contents>
Yes. XML generally ignores whitespace, although you can turn this feature on/off in most XML processors. Within a tag, it makes no difference whatsoever.
This is also equivalent:
<contents cpid="1" cpnm="1"/>
Your last example has a newline inside the contents. This can make a difference, at least with some XML parsers with some settings applied.
No! Both contain different count of XML nodes.
If you try to get the first child in the first case, you get nothing. In the second case, you get a text element with a simple '\n' content.
Even in XSLT transformations you may get different results - watch for e.g. "position()" function of XPath.
More information: http://www.oracle.com/technology/pub/articles/wang-whitespace.html