一个XML转换的例子
問:
我想把字符串轉(zhuǎn)換成stream,
然后
System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader(System.IO.Stream input)
______________________________________________________________________________________________
答1:
為何一定要轉(zhuǎn)呢?
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);
轉(zhuǎn)載于:https://www.cnblogs.com/qyz123/archive/2007/11/11/955622.html
總結(jié)
以上是生活随笔為你收集整理的一个XML转换的例子的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CF1129D Isolation(分块
- 下一篇: Git missing Change-I