Skip to main content

Tip: Achieving vendor independence with SAX

How to use SAX and a SAX helper class to achieve vendor independence

Return to article


Using the XMLReaderFactory with Java system properties (parser independent)


// Obtain an instance of an XMLReader implementation from a system property
XMLReader parser = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
// Do normal parsing tasks
parser.setContentHandler(new MyContentHandler());
parser.parse(new InputSource("file:///usr/local/projects/xml/test.xml");

Return to article