Why I get an error when displaying a XML file?

S

shapper

Hello,

How to load a XML document and display it immediately after in the
browser?

Dim doc As New System.Xml.XmlDocument
doc.Load("~/XMLFile.xml")
Context.Response.ContentType = "text/xml; charset=utf-8"
Context.Response.Write(siteMap)

I tried this but I am getting a parser error:
XML Parsing Error: syntax error
Location: http://localhost:2736/GaragemRamos 2006a/_Lab.aspx
Line Number 1, Column 1:System.Xml.XmlDocument
^

This is very strange because I can't see any error in my XML sample
file:

<?xml version="1.0" encoding="utf-8" ?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>two of our famous Belgian Waffles with plenty of real
maple syrup</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>light Belgian waffles covered with strawberries and
whipped cream</description>
<calories>900</calories>
</food>
</breakfast_menu>

Thanks,
Miguel
 
K

Karl Seguin [MVP]

It looks good...

Maybe you can try to Response.Clear() before sending anything out and making
sure to Response.End() after so nothing else gets added to the output
stream...

Karl
 
M

Morten Wennevik

Hi Miguel,

You are sending some values as regular response either before or after
writing the xml.
You need to close the response with Context.Response.End() after writing
the xml, and maybe also Context.Response.Clear() before you write the xml.
 
S

shapper

Hi,

I solved it using your sugestion and changing the last code line to:
Context.Response.Write(siteMap.OuterXml)

Thanks,
Miguel
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top