You can't go very far in XML without learning these two important terms. XML data is said to be well-formed if it follows all of the XML syntax and grammar rules (matching tags, etc.). Often a simple check for well-formed data can help spot typos in XML files. That's already an advantage when the data you are dealing with holds configuration information like the machine database excerpted above.
XML data is said to be valid if it conforms to the rules we've set down in one of the data definition mechanisms mentioned earlier. For instance, if your data file conforms to its DTD, it is valid XML data.
Valid data by definition is well-formed, but the converse does not have to be true. It is possible to have perfectly wonderful XML data that does not have an associated DTD or schema. If it parses properly, it is well-formed, but not valid.
Copyright © 2001 O'Reilly & Associates. All rights reserved.