一个XML转换的例子
问:
我想把字符串转换成stream,
然后
System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader(System.IO.Stream input)
______________________________________________________________________________________________
答1:
为何一定要转呢?
string xmlFrag ="<book> " +
"<title>Pride And Prejudice</title>" +
"<bk:genre>novel</bk:genre>" +
"</book>";
//Create the XmlNamespaceManager.
NameTable nt = new NameTable();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
nsmgr.AddNamespace("bk", "urn:sample");
//Create the XmlParserContext.
XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
//Create the reader.
XmlTextReader reader = new XmlTextReader(xmlFrag, XmlNodeType.Element, context);
转载于:https://www.cnblogs.com/qyz123/archive/2007/11/11/955622.html
总结
以上是生活随笔为你收集整理的一个XML转换的例子的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: CF1129D Isolation(分块
- 下一篇: Git missing Change-I