我有一个 xml 字符串:
<Test> Result : this is the result</Test>
我如何使用 XMLReader 类解析 XML 以将“this is the result”作为字符串返回。
谢谢!
请您参考如下方法:
var r = System.Xml.XmlReader.Create(new System.IO.StringReader("<Test> Result : this is the result</Test>"))
while (r.Read()) {
if (r.NodeType == XmlNodeType.Element && r.LocalName == "Test") {
Console.Write(r.ReadElementContentAsString());
}
}
