Read XML file into XmlDocument

后端 未结 5 1061
孤街浪徒
孤街浪徒 2020-12-24 00:11

I am very new to C#. I have XML file (text.xml). I want to read that in XmlDocument and store the stream in string variable.

5条回答
  •  旧巷少年郎
    2020-12-24 00:51

    Use XmlDocument.Load() method to load XML from your file. Then use XmlDocument.InnerXml property to get XML string.

    XmlDocument doc = new XmlDocument();
    doc.Load("path to your file");
    string xmlcontents = doc.InnerXml;
    

提交回复
热议问题