XmlTextReader issue
Posted
by Stanislav Palatnik
on Stack Overflow
See other posts from Stack Overflow
or by Stanislav Palatnik
Published on 2010-03-28T01:24:59Z
Indexed on
2010/03/28
1:33 UTC
Read the original article
Hit count: 285
I'm try to parse this xml, but c# keeps throwing an exception saying it has invalid characters. I can't copy the text from the messagebox directly, so I've screened it.
http://img29.imageshack.us/img29/694/xmler.jpg
Here's the code to get the string
string strRetPage = System.Text.Encoding.GetEncoding(1251).GetString(RecvBytes, 0, bytes);
while (bytes > 0)
{
bytes = socket.Receive(RecvBytes, RecvBytes.Length, 0);
strRetPage = strRetPage + System.Text.Encoding.GetEncoding(1251).GetString(RecvBytes, 0, bytes);
}
int start = strRetPage.IndexOf("<?xml");
string servReply = strRetPage.Substring(start);
servReply = servReply.Trim();
servReply = servReply.Replace("\r", "");
servReply = servReply.Replace("\n", "");
servReply = servReply.Replace("\t", "");
XmlTextReader txtRdr = new XmlTextReader(servReply);
© Stack Overflow or respective owner