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>))
精彩评论