Sto provando ad analizzare questo xml, ma C# continua a lanciare un'eccezione dicendo che ha caratteri non validi. Non riesco a copiare il testo direttamente dalla messagebox, quindi l'ho sottoposto a screening.Edizione XmlTextReader
http://img29.imageshack.us/img29/694/xmler.jpg
Edit: il testo copiato
<?xml version="1.0" encoding="UTF-8"?><user><id>9572</id><screen_name>fgfdgfdgfdgffg44</screen_name></user>
Ecco il codice per ottenere la stringa
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);
}
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);
È possibile premere Ctrl + C per copiare il testo di un MessageBox standard. – SLaks
Grazie per il suggerimento. Ora l'ho testato con HexEdit e pulito:/ –
stai usando .net 3.5? In tal caso, perché non usare LINQ in XML? Fare manipolazioni di stringhe su XML è puro masochismo! :) –