| ||||||||
IsWellFormed Methodbool CMarkup::IsWellFormed() const; You may need to determine if the CMarkup object contains a well-formed XML document at a later point than the call to SetDoc such as in a situation where the object has been passed to a function in your program and you don't know if it contains a well-formed XML document. Simply call CMarkup xml( "<msg>Hello" ); // no end tag! bool bWell = xml.IsWellFormed(); // false With CMarkup, a "well-formed" document is one which has been successfully parsed with a single root element and all child elements contained properly. This method indicates whether the document appears to be a well-formed XML document although it is not a guarantee of XML compliance. See also Containment Hierarchy.
You're right, it is not a properly composed XML document because of the unencoded ampersand in the element data but CMarkup does not check encoding correctness. As described above, the CMarkup is designed for quick processing to extract and modify information in documents rather than any kind of strict encoding check. In fact the role of strictness for the sake of rejecting entire documents is often counter-productive as discussed in The Problem With DTD and XML Schema Validation, since what is more important is verifying that the data extracted is safe and acceptable from the logic where the data is utilized. There is currently no function to verify that element data is encoded properly. But you can test documents using the Alt+F7 MSXML Validate function in the free firstobject XML Editor. | ||||||
|
Posted August 1, 2001 updated May 14, 2007. Question or comment about this article? ©Copyright 2008 First Objective Software, Inc. All rights reserved. |