I wasn\'t aware of a difference, but a coworker says there is, although he can\'t back it up. What\'s the difference if any?
See XML DTD on W3 Schools:
An XML document with correct syntax is called "Well Formed".
An XML document validated against a DTD is both "Well Formed" and "Valid".
In addition to the aforementioned DTD's, there are 2 other ways of describing and validating XML documents are XMLSchema and RelaxNG, both of which may be easier to use and support more features than DTD.
If XML is confirming to DTD rules then it's a valid XML. If a XML document is conforming to XML rules (all tags started are closed,there is a root element etc)then it's a well formed XML.
Well-Formed XML is XML that meets the syntactic requirements of the language. Not missing any closing tags, having all your singleton tags use <whatever />
instead of just <whatever>
, and having your closing tags in the right order.
Valid XML is XML that uses a DTD and complies with all its requirements. So if you use an attribute improperly, you violate the DTD and aren't valid.
All valid XML is well-formed, but not all well-formed XML is valid.
Valid XML is XML that succeeds validation against a DTD.
Well formed XML is XML that has all tags closed in the proper order and, if it has a declaration, it has it first thing in the file with the proper attributes.
In other words, validity refers to semantics, well-formedness refers to syntax.
So you can have invalid well formed XML.
Well, XML that isn't well formed, sort of by definition, isn't XML. Poeple usually refer to valid XML as XML that adheres to a certain schema (XSD or DTD).