XML is a standard for defining markup languages. Because XML syntax is standardised, you don't need to write a new tokeniser or parser for each application. Using XML aids in portability of data between programs. Syntax and validity of documents can be checked independently. An XML parser reads text with XML markup.
Parsers usually depend on the well formedness of a document.
Some can determine the validity. There are two common models of interaction between the parser and your program. SAX SAX provides an event based interface to the parser. The callbacks are passed the data associated with the tag or the text of the character data. This interface is good for large XML files where the processing required is linear.