posted 24 years ago
The difference is actually quite simple.
A well-formed XML document is one which fully adheres to the syntax of XML. This includes things like all tags are closed, tags are properly nested (ie <a><b>blah</b></a> ) and don't cross
over (ie not <a><b>blah</a></b> ), all contentious ('<' '>' '&' ''') characters are escaped and so on.
A valid XML document is one which is well-formed, but also correctly implements its specified DTD.
Both are useful; You don't always want the overhead of DTD checking, and many XML tools are generic enough that they will work on any well-formed XML, regardless of DTD. On the other hand, it is often vital to make sure that some XML is valid against the required DTD before starting expensive processing.
Some available parsers provide validity checking, but some only check for well-formed XML. Make sure that the parser you chose does what you need.