Dom parsing with a attribute name with a number sign
Hey
I am trying to parse some xml from a ArcIms service, and in the result
xml, one of the attribute names contain a number sign, like #. When I
trying to parse this xml I get the folowing exception:
[Fatal Error] :1:49: Element type "FIELDS" must be followed by either
attribute specifications, ">" or "/>".
Exception in thread "main" org.xml.sax.SAXParseException: Element type
"FIELDS" must be followed by either attribute specifications, ">" or
"/>".
I have made this small demo program to illustratet my problem:
<java program>
import java.io.ByteArrayInputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
public class Demo{
public static void main(String[] args) throws Exception {
String xmlString = "<?xml version='1.0' encoding='UTF-8' ?>"+
"<FIELDS #SHAPE#='[Geometry]' />";
byte[] byteArr =xmlString.getBytes();
ByteArrayInputStream bais = new ByteArrayInputStream(byteArr);
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource inputSource = new InputSource(bais);
Document document = builder.parse(inputSource);
}
}
</java>
What can I do to solve this problem.