Read XML file into XmlDocument

后端 未结 5 1057
孤街浪徒
孤街浪徒 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:44

    Hope you dont mind Xml.Linq and .net3.5+

    XElement ele = XElement.Load("text.xml");
    String aXmlString = ele.toString(SaveOptions.DisableFormatting);
    

    Depending on what you are interested in, you can probably skip the whole 'string' var part and just use XLinq objects

提交回复
热议问题