Archived Forum Post

Index of archived forum posts

Question:

CkXml(C++): the formatting of a empty-content element may change after LoadXml()?

Sep 14 '13 at 04:10

Hi, dear sir,

we found the formatting of a empty-content element may be changed after LoadXml(), comapred with getXml(). "may" refer to some of them using a start-tag immediately followed by an end-tag has being converted to empty-element tag, and others may not. (version: 20101223_ChilkatVC8)

Q1. What is the logic for the conversion? Q2. Do we have any switch to disable the conversion?

thanks -- Stanley


Answer

XML is a standard such that the identical thing can be represented in a multitude of different ways. For example, "<abc></abc>" and "<abc />" both represent exactly the same thing. Also, whitespace is meaningless, and therefore the XML standard allows for XML documents to be beautified with indenting to make for easy readability. It should make no difference whether XML tags occur one after the other on a single line, or on separate lines nicely indented.

Any program that reads/writes XML should be capable of handling any given representation. It would be impossible for Chilkat to satisfy the special needs of all possible programs that have limitations because they are incapable of handling specific parts of the XML standard.

Chilkat XML is a DOM oriented parser -- meaning that when XML is parsed it is loaded into an internal document object model. When re-written, it is written from the DOM, and there may be whitespace, formatting, or other inconsequential changes. This is impossible to avoid.


Answer

Yes, you are right. and I totally agree with you.

I just wondering why some of them will be reformatted and others may not.

I am looking for a easy way for xml content comparison. just make sure a .net frameword-generated xml string from our third party partner cannot use string compare to expect that i can provide/return the same string after i load into ckxml.

thanks a lot

--

stanley