如何读取作者返回的xml [英] how to read xml which is return by the writer

查看:104
本文介绍了如何读取作者返回的xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在字符串构建器中编写xml文件,然后返回Xml。现在我想读一下Xml文件的内容。但是为了阅读我如何将该返回值传递给doc.load(),

I am writing a xml file in a string builder and then returning the Xml. Now i want to read that Xml file content . But for reading how i pass that return value to doc.load(),

推荐答案

XmlDocument.Load [ ^ ]有四个重载 - 其中一个需要一个流。



所以,将StringBuilder转换为流:

XmlDocument.Load[^] has four overloads - one of them takes a stream.

So, convert your StringBuilder to a stream:
StringBuilder sb = new StringBuilder();
...
Stream stream = new MemoryStream(System.Text.Encoding.Unicode.GetBytes(sb.ToString()))

并将其传递给XmlDocument

and pass that to the XmlDocument


这篇关于如何读取作者返回的xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆