Transformer Class for XML in web based app.

Hi

I have used DOM to read XML node values and DOM's Transformer class to save changed xml node values back to the xml file.

File f =new File("C:\\test.xml");

DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();

DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();

Document doc = docBuilder.parse(f);

I have changed the value of a node using setData method of Text.

Then saved the XML file again:

Source source =new DOMSource(doc);

Result res =new StreamResult(f);

Transformer x = TransformerFactory.newInstance().newTransformer();

x.transform(source,res);

It works fine.

But when I have a web based application, I put this code in a servlet and the xml file in WEB INF, it reads it and changes the node value but does not save the file when I use Transformer.

Does it not work for web based applications. Is there any other way out.

[1106 byte] By [PremMa] at [2007-10-3 9:46:57]
# 1
dont you think it's a bit unlogical to give use a bit of working code, complaining about other code not working?what's the path you provide for the file in the servlet?
alban.maillerea at 2007-7-15 5:03:50 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...