首页 新闻 会员 周边

用过socket收到的字节流能直接转换成xdocument类型吗

0
悬赏园豆:5 [已关闭问题]

用过socket收到的字节流能直接转换成xdocument类型吗

问题补充: 怎么转成TextReader呢
拖鞋王子的主页 拖鞋王子 | 初学一级 | 园豆:37
提问于:2010-02-08 09:33
< >
分享
其他回答(2)
0

不能,得先转换成TextReader

再用XDocument.Load方法读取

贼寇在何方 | 园豆:255 (菜鸟二级) | 2010-02-08 11:10
0

需要将字节流转换成字符流

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);
                }
            }

查尔斯 | 园豆:3832 (老鸟四级) | 2010-02-08 13:58
0

直接用 XmlTextReader(Stream) 读字节流就可以了,不需要先转字符流再转XML。

eaglet | 园豆:17139 (专家六级) | 2010-02-09 06:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册