关于网友提出的“用过socket收到的字节流能直接转换成xdocument类型吗”问题疑问,本网通过在网上对“用过socket收到的字节流能直接转换成xdocument类型吗”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题:用过socket收到的字节流能直接转换成xdocument类型吗
描述:用过socket收到的字节流能直接转换成xdocument类型吗
解决方案1:直接用 XmlTextReader(Stream) 读字节流就可以了,不需要先转字符流再转XML。
解决方案2:需要将字节流转换成字符流
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
解决方案3:不能,得先转换成TextReader
再用XDocument.Load方法读取
以上介绍了“用过socket收到的字节流能直接转换成xdocument类型吗”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/1082257.html