For reading XML, there is SAX and DOM built into Java 1.5. You can use JAXP and not need to know details about what parser is available... So, what are some prescribed APIs for one to write XML documents in Java 1.5 and earlier?
Ideally, a read-and-write with no changes is just a few lines of code.
Java 1.4 comes with javax.xml.transform, which can take a DOMSource, SAXSource, etc:
// print document
InputSource inputSource = new InputSource(stream);
Source saxSource = new SAXSource(inputSource);
Result result = new StreamResult(System.out);
TransformerFactory transformerFactory = TransformerFactory
.newInstance();
Transformer transformer = transformerFactory
.newTransformer();
transformer.transform(saxSource, result);
If you want to go back to the J2SE 1.3 API, you're pretty much on your own (though if you're on the J2EE API of that era, there might be something - I don't recall).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With