开发者

parse XML from string

开发者 https://www.devze.com 2022-12-27 07:45 出处:网络
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.

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

精彩评论

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