Parsing with SAX

Hi,

I'm trying to add a node to an existing XML file.

This is my code so far.

try {

DefaultHandler handler = new DefaultHandler();

FileInputStream tofile = new FileInputStream("file.xml");

Element newtopic = (Element)moXmlDocument.createElement(title);

SAXParserFactory fac = SAXParserFactory.newInstance();

SAXParser parser = fac.newSAXParser();

parser.parse(tofile, handler);

But I'm not sure where to go from here? Is there a method with DefaultHandler which will return the root node of the XML file so I can append a new node to it?

Any help is greatly appreciated.

[646 byte] By [macgabja] at [2007-9-27 12:47:45]
# 1
Try, using JDOM:SAXBuilder builder = new SAXBuilder();Document doc = builder.build("path");// do here the manipulation you want on your treeXMLOutputter outputter = new XMLOutputter(...);outputter.output(...);
amaurydeboua at 2007-7-9 8:00:23 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...