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 ?