Dom parsing with a attribute name with a number sign

lars.charmer

Usenet Archive
Joined
Sep 19, 2006
Messages
3
Reaction score
0
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.
 

Andrew Thompson

Usenet Archive
Joined
Jan 16, 2003
Messages
9,476
Reaction score
0
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 "/>". .... String xmlString = "<?xml version='1.0' encoding='UTF-8' ?>"+ "<FIELDS #SHAPE#='[Geometry]' />";

This suggest to me that '#' is not a valid character for XML attributes.
What can I do to solve this problem.

Use valid XML?

Andrew T.
 

lars.charmer

Usenet Archive
Joined
Sep 19, 2006
Messages
3
Reaction score
0
Easy for you to say. This service/server have returned this kind off response for the last 6 year, and don't think that ESRI (the company who's making the ArcIms server), is goving to change it just for me.

Andrew Thompson skrev:
 

lars.charmer

Usenet Archive
Joined
Sep 19, 2006
Messages
3
Reaction score
0
skrev:
Easy for you to say. This service/server have returned this kind off response for the last 6 year, and don't think that ESRI (the company who's making the ArcIms server), is goving to change it just for me.

Andrew Thompson skrev:

Okay it is easy(Sorry Andrew T.). Esri do support valid XML, I just have to specify you want that. They have a attribute callede outmode and that should have the value "newxml". But what was they suppose to when they introduced a invalid XML, and every body was using it, becaurse that was the default value.

Best regards
Lars Charmer Jørgensen
 

Andrew Thompson

Usenet Archive
Joined
Jan 16, 2003
Messages
9,476
Reaction score
0

Huh? Your decision to put that comment - floating at
the top, out of context, makes it hard to understand
what you are referring to.

Also - where did the extra indents come from?

The use of '>' preceding your text makes it appear
as if that first paragraph was *quoted* by you.
....
Okay it is easy(Sorry Andrew T.).

I never implied it was easy. (And I don't see the need for apologies.)
..Esri do support valid XML, I just
have to specify you want that.

I want world peace. This is just an interesting diversion.

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,246
Members
248,133
Latest member
DujonT

Latest Threads

Top