An XML parsing library first will check that any document you pass it is well-formed: the character encodings are valid, tags are properly closed, tag names are valid identifiers, and so on.