Decoding question

G

GTi

I have this snippet function:


string buf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rows>\n";
buf += "<row id=\"1\">\n";
buf += "<cell>2</cell>\n";
buf += "<cell>S&P 11</cell>\n";
buf += "</row>\n";

Page.Response.Clear();
Page.Response.ContentType = "text/xml";
Page.Response.Write(buf);
Page.Response.BufferOutput = true;
Page.Response.Expires = 0;
Page.Response.End();

This one gived me a nice error message in the browser:
XML Parsing Error: not well-formed
Location: http://127.0.0.1/xmfile.aspx?DoGenerateXmlFile=1
Line Number 4, Column 10:<cell>S&P 11</cell>

I know this is the most common xml error, but how can I avoid this?
How can I force the output to be UTF-8 encoded ?
 
G

Guest

I get the impression the first line with the XML declaration is ignored and
the problem is that you dont close the <rows> element.

HTH

Ciaran O'Donnell
 
G

GTi

Ciaran said:
I get the impression the first line with the XML declaration is ignored and
the problem is that you dont close the <rows> element.

HTH

Ciaran O'Donnell

The Rows is closed - just missed that in the snippet - sorry!
 
S

Stoitcho Goutsev \(100\)

GTi,

The first error that I get is for using the &. You should use &amp; instead.

The second error is for not closed <rows> tag.

When I fixed bot problems the XML showed up.
 

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

Top