Posted By:
krishnakanth_r
Posted On:
Wednesday, May 9, 2001 10:40 PM
My requirement is to have a integer value as Element name.Iam trying to creat xml using dom(java).Java codes follows ,its throws Exception.Can any one help me. import javax.xml.parsers.*; import org.w3c.dom.*; import com.sun.xml.tree.*; import org.w3c.dom.*; import org.xml.sax.*; public class XMLTest { public static void main(String args[]) { try { XmlDocumentBuilder builder = new XmlDocumentBuilder(); XmlDocument document = builder.createDocument(); Element root = document.createElement("Payroll"); Element row = null; row = document.createElement("employee"); Element data = document.createElement(&qu
More>>
My requirement is to have a integer value as Element name.Iam trying to creat xml using dom(java).Java codes follows ,its throws Exception.Can any one help me.
import javax.xml.parsers.*;
import org.w3c.dom.*;
import com.sun.xml.tree.*;
import org.w3c.dom.*;
import org.xml.sax.*;
public class XMLTest
{
public static void main(String args[])
{
try
{
XmlDocumentBuilder builder = new XmlDocumentBuilder();
XmlDocument document = builder.createDocument();
Element root = document.createElement("Payroll");
Element row = null;
row = document.createElement("employee");
Element data = document.createElement("1234");
data.appendChild(document.createTextNode("6789.10"));
row.appendChild(data);
root.appendChild(row);
document.appendChild(root);
System.out.println(root.toString());
}
catch(Exception e) {
System.out.println( "Exception caught : " + e.getMessage());
}
}
}
<<Less