I need to convert an XML string into an XmlElement

后端 未结 5 818
一个人的身影
一个人的身影 2020-12-14 00:05

I\'m looking for the simplest way to convert a string containing valid XML into an XmlElement object in C#.

How can you turn this into an XmlEleme

5条回答
  •  感动是毒
    2020-12-14 00:10

    I tried with this snippet, Got the solution.

    // Sample string in the XML format
    String s = " No Records found !";
    // Create the instance of XmlDocument
    XmlDocument doc = new XmlDocument();
    // Loads the XML from the string
    doc.LoadXml(s);
    // Returns the XMLElement of the loaded XML String
    XmlElement xe = doc.DocumentElement;
    // Print the xe
    Console.out.println("Result :" + xe);
    

    If any other better/ efficient way to implement the same, please let us know.

    Thanks & Cheers

提交回复
热议问题