LoadXml failing because field too long????

A

Adam Sandler

Hello,

I'm reusing a method here which sends a query to the database and
returns the results formatted as XML.

In the codebehind, I call the method we reuse here (and have
successfully many times before) and then shove the results in LoadXml:

Dim d As New XmlDocument
d.LoadXml(qXML)

Each column in the DB essentially becomes a field in the XML... like
so (this sample is taken directly from the output of MsgBox(qXML)):

<?xml version="1.0" encoding ="UTF-8">
<RESPONSE>
<FEATURES>
<FEATURE>
<ENVELOPE minx="3180000" miny="1430000" maxx=""3180000 maxy
="1430000" />
<FIELDS>
<FIELD name="FID" value="0" />
<FIELD name="#SHAPE#" value="[Geometry]" />
<FIELD name="USGS_ID" value="7103780" />
<FIELD name="DESCRIPTO" value="MONUMENT CREEK" />
<FIELD name="URL"
value="http://waterdata.usgs.gov/co/nwis/uv?
dd_cd=01%2C03%2C04&format=gif&period=7&site_no=07103780" />
</FIELDS>
</FEATURE>
</FEATURES>
</RESPONSE>

It appears there may be a line break in "FIELD name="URL""... the
value attribute appears on the next line. Does white space matter
here? I ask because the following error is being thrown at runtime:

Server Error in '/Website1' Application.
--------------------------------------------------------------------------------

'=' is an unexpected token. The expected token is ';'. Line 12,
position 88.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Xml.XmlException: '=' is an unexpected
token. The expected token is ';'. Line 12, position 88.

Line 12 is exactly where I noticed the break between FIELD name="URL"
and value="" occurs! The data returned from the database, the url, is
over 80 characters long. Is this too much for an XML value? Or is
there a way to code it so the break and or character limitation can be
accounted for?

Suggestions are greatly appreciated.

Thanks!
 
M

Martin Honnen

Adam said:
<?xml version="1.0" encoding ="UTF-8">
<RESPONSE>
<FEATURES>
<FEATURE>
<ENVELOPE minx="3180000" miny="1430000" maxx=""3180000 maxy
="1430000" />
<FIELDS>
<FIELD name="FID" value="0" />
<FIELD name="#SHAPE#" value="[Geometry]" />
<FIELD name="USGS_ID" value="7103780" />
<FIELD name="DESCRIPTO" value="MONUMENT CREEK" />
<FIELD name="URL"
value="http://waterdata.usgs.gov/co/nwis/uv?
dd_cd=01%2C03%2C04&format=gif&period=7&site_no=07103780" />
^^^^^^^
The problem is the unescaped ampersand, you need to use
&amp; (& a m p ; for web forum readers)
to escape the ampersand. The same for the other two ampersands.
 

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
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top