开发者

parse XML from string

I have a xml string:

<Test&开发者_高级运维gt; Result : this is the result</Test>

How do i parse XML using XMLReader class to get "this is the result" as a string back.

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());
   }
}


Just create an xml reader using that string and use it for parsing

var reader = System.Xml.XmlReader.Create(new System.IO.StringReader(<xmlstring>))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜