如何从 XmlReader 创建 XML 文件?
如何从 System.Xml.XmlReader 写入 XML 文件?
我认为这是一个简单的问题,但每当我搜索时,我似乎最终都会将文件读取给读取器或逐个节点写入。
XmlReader 对象传送存储在数据库中的 xml,只需从数据库中取出到文件即可。有什么简单的方法可以做到这一点吗?
SqlCommand dataCmd = new SqlCommand(sqlText, Conn);
System.Xml.XmlReader dataReader = null;
dataCmd.CommandTimeout = 60000;
Conn.Open();
dataReader = dataCmd.ExecuteXmlReader();
dataReader.Read();
How do you write an XML file from an System.Xml.XmlReader?
I thought this would be a simple question but whenever I search I seem to be ending up with reading the file to a reader or writing node by node.
The XmlReader object conveys xml that was stored in a database and just needs to come out of the database to a file. Is there any easy way to do this?
SqlCommand dataCmd = new SqlCommand(sqlText, Conn);
System.Xml.XmlReader dataReader = null;
dataCmd.CommandTimeout = 60000;
Conn.Open();
dataReader = dataCmd.ExecuteXmlReader();
dataReader.Read();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要创建一个
XmlWriter
并调用其WriteNode
方法。例如:
You need to create an
XmlWriter
and call itsWriteNode
method.For example:
最简单的方法是将其传递到 XmlWriter,使用如下方法:
The simplest way would be to pass it into an XmlWriter, using a method such as this: