XML Parsing refers to going through an XML document in order to access or modify data.
XML Parser provides a way to access or modify data in an XML document. Java provides multiple options to parse XML documents. Following are the various types of parsers which are commonly used to parse XML documents.
Dom Parser − Parses an XML document by loading the complete contents of the document and creating its complete hierarchical tree in memory.
SAX Parser − Parses an XML document on event-based triggers. Does not load the complete document into the memory.
JDOM Parser − Parses an XML document in a similar fashion to DOM parser but in an easier way.
StAX Parser − Parses an XML document in a similar fashion to SAX parser but in a more efficient way.
XPath Parser − Parses an XML document based on expression and is used extensively in conjunction with XSLT.
DOM4J Parser − A java library to parse XML, XPath, and XSLT using Java Collections Framework. It provides support for DOM, SAX, and JAXP.
There are JAXB and XSLT APIs available to handle XML parsing in object-oriented way. We'll elaborate each parser in detail in the subsequent chapters of this tutorial.