[英]parse XML from string
I have a xml string: 我有一个xml字符串:
<Test> Result : this is the result</Test>
How do i parse XML using XMLReader class to get "this is the result" as a string back. 我如何使用XMLReader类解析XML以将“this is the result”作为字符串返回。
thanx ! thanx!
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());
}
}
只需使用该字符串创建一个xml阅读器并将其用于解析
var reader = System.Xml.XmlReader.Create(new System.IO.StringReader(<xmlstring>))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.