SAXReader
You can use the SAXReader as a normal SAX driver by defining org.xml.sax.driver=org.brains2b.saxo.SAXReader
through the system properties. You can also call SAXReader reader = new SAXReader() directly
SAXWriter
You can just create a SAXWriter by calling SAXWriter writer=new SAXWriter(java.io.Writer)
or SAXWriter writer=new SAXWriter(String fileName)
The SAXWriter has a comparable interface to ContentHandler so you can just write an XML file as you would read one:
Before starting to write call startDocument()
and end writing by calling endDocument()
.
If you want the xml definition at the start call insterDescriptor()
The normal startElement and endElement are provided, but if you want to write an element with only attributes you can use insertElement(..)
You can use startComment()
, setContent(String)
and endComment()
to write comments to your XML file
Note for JDK1.3 users
This version of Saxo relays on the org.sax.* classes supplied with JDK1.4 and further. While these were not present in JDK 1.3 to use Saxo you need
to download the interface separatly and include it in your classpath