parse XML from string

前端 未结 2 1593
耶瑟儿~
耶瑟儿~ 2021-01-24 08:42

I have a xml string:

 Result : this is the result

How do i parse XML using XMLReader class to get \"this is the result

相关标签:
2条回答
  • 2021-01-24 09:24

    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 讨论(0)
  • 2021-01-24 09:28
    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());
       }
    }
    
    0 讨论(0)
提交回复
热议问题