In this post under JAXP, I will explain how to add custom error handler when parsing xml document through SAX api. To provie a custom error handler, we need to implement the interface org.xml.sax.ErrorHandler as shown below package sax; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; public class CustomErrorHandler implements ErrorHandler { @Override public void error(SAXParseException…… Continue reading Custom Error Handling when parsing xml through SAX api
Category: JAXP
Parsing xml document using DOM api
In this post I will explain how to parse a xml document using DOM api. The DOM api can also be used to create xml documents in addition to reading. The DOM compliant parser loads the entire document in memory for reading it. Once the entire xml document is loaded in the memory, we can…… Continue reading Parsing xml document using DOM api
Parsing xml document with SAX API
In this post I will explain how to parse an xml document in java using the SAX API. SAX api is event based java api. The SAX compliant parser which reads the xml document sequentially, generates events whenever the parser encounters an xml element. The parser reads the document sequentially and doesn’t load the entire…… Continue reading Parsing xml document with SAX API