Java StAX: XMLInputFactory
Jakob Jenkov |
The class javax.xml.stream.XMLInputFactory
is a root component of the Java StAX API.
From this class you can create both an XMLStreamReader
and an XMLEventReader
.
Here are two examples:
XMLInputFactory factory = XMLInputFactory.newInstance(); XMLEventReader eventReader = factory.createXMLEventReader( new FileReader("data\\test.xml")); XMLStreamReader streamReader = factory.createXMLStreamReader( new FileReader("data\\test.xml"));
XMLInputFactory Properties
You can set various properties on the XMLInputFactory
instance using the
setProperty()
method. Here is an example:
factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true);
For a full list of properties and their meaning, see the official JavaDoc (in Java 6) for the StAX API.
Tweet | |
Jakob Jenkov |