Does the DOM require Well-Formed XML?
The DOM assumes that an XML document which is read in is well-formed, since otherwise the XML processor which builds the DOM structure model has to stop with a fatal error, as per the XML specification. However, it is possible to carry out some editing operations using the DOM which would result in a non-WF XML document if the document were to be naively serialized. Examples are allowing “–” in comments, or not fixing up namespace URI / prefix bindings, or allowing the insertion of a character which isn’t legal XML. If the document is serialized, the serializer is expected to fix the problem, e.g. by modifying the comment appropriately, or choosing an appropriate character encoding to make the character legal XML. This issue is expected to be resolved in Level 3.