XML Question
Hi,
We are developing one application in which at present we are in need of transactions with the XML file.All these days we were only reading from the XML file and passing it on to the client after processing it in our EJB server program..But, the present requirement wants us to do, not only reading but also, adding/deleting/editing nodes to the xml file programmatically.I hv taken the module of adding nodes to the xml file.Following is the codec I hv given for adding the new node for the xml file...This perticular codec is not giving any error, after executing the code it says that the node is added successfully but, if I open the xml file again both programatically and manualy the added node is not show at all...Can anybody tell me what might be the problem with the following code and also tell if something hv been missed out in the same.I will be very much thankfull to you if U can tell me the exact steps to be followed to make the following code work properly;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
// Get the document handle to which the node to be added.
Document doc = db.parse(convertToFileURL(filename));
// Create the new element that is to be added.
Element elem=doc.createElement("G555007");
// Get the element under which the node to be added...Here code is
// the parent node.
NodeList nl = doc.getElementsByTagName(code);
// Append the created new node to the parent node got.
Node nod=nl.item(0).appendChild(doc.createTextNode("G555007"));
// Print the following line after appending the node.
System.out.println("Node appended.............");
-
Thanks and Regards,
Ram...

