Java - XML question????

Ram <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
Hi,

        When I was trying to write into the XML file from my Java program.      Everything was fine programatically,  my program was not giving any errors and was shoeing the proper results when I run the program but, the same is not effective in the xml file saved in the same directory.   Can anybody tell me how to save the same after adding the nodes.    Following is my codec:
------
 public boolean addElem(String code, String filename) {
  try {
   DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   DocumentBuilder db = dbf.newDocumentBuilder();
   Document doc = db.parse(convertToFileURL(filename));

   Node rootNode = doc.getDocumentElement();
   NodeList list = doc.getElementsByTagName("G010101");

   // Loop through the list.
   for (int i=0; i < list.getLength(); i++) {
     Node thisNode = list.item(i);
     Node newNode = doc.createElementNS(convertToFileURL(filename),"G555007");

     Node newCodeNode = doc.createElementNS(convertToFileURL(filename),"code");
     Text tnNode = doc.createTextNode("Kona");
     newCodeNode.appendChild(tnNode);

     Node newMsgNode = doc.createElementNS(convertToFileURL(filename),"message");
     Text tpNode = doc.createTextNode("Newly Inserted Node......");
     newMsgNode.appendChild(tpNode);

     newNode.appendChild(newCodeNode);
     newNode.appendChild(newMsgNode);
     rootNode.insertBefore(newNode, thisNode);
     rootNode.normalize();
     rootNode.appendChild(newNode);
     break;
   }

Thanks and Regards,
Ram....
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.