Re: Java - XML question????
Ram <[email protected]>
| Newsgroups | gmane.comp.java.sun.servlet |
|---|---|
| Message-ID | <[email protected]> |
Thank you Adi,
But how to check the file permission to write into the xml, Also tell me how to set it...
Regards,
Ram...
----- Original Message -----
From: Adrian Smaranda
To: [email protected]
Sent: Tuesday, April 29, 2003 6:28 PM
Subject: Re: Java - XML question????
Hi Ram,
Check your file permissions. You should have permissions to write into the xml file.
Adi.
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet API Technology. [mailto:[email protected]]On Behalf Of Ram
Sent: Tuesday, April 29, 2003 3:33 PM
To: [email protected]
Subject: Java - XML question????
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....