How do I write an XML string to a file?

前端 未结 4 1418
一生所求
一生所求 2020-12-06 04:20

I have a string and its value is:


    qwerty
    adsf 
    The text of the samp         


        
4条回答
  •  眼角桃花
    2020-12-06 04:53

    Try this:

    string s = "";
    XmlDocument xdoc = new XmlDocument();
    xdoc.LoadXml(s);
    xdoc.Save("myfilename.xml");
    

    Has the added benefit that the load will fail if your XML is invalid.

提交回复
热议问题