Can we have Element name as integer i.e !_NEWLINE_!<1234>6789.10</1234>
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

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

Re: Can we have Element name as integer i.e !_NEWLINE_!&lt;1234&gt;6789.10&lt;/1234&gt;

Posted By:   AlessandroA_Garbagnati  
Posted On:   Wednesday, May 9, 2001 11:23 PM

Hi,

No, according to XML Specifications:

A Name is a token beginning with a letter or one of a few punctuation characters, and continuing with letters, digits, hyphens, underscores, colons, or full stops, together known as name characters.
About | Sitemap | Contact