简体   繁体   中英

how to save XML URL content into text file using C#

I want to save Xml Url content into text file using C# I tried this code

System.Xml.XmlTextReader _XmlTextReader = new System.Xml.XmlTextReader("http://www.w3schools.com/php/links.xml");
        string_xmlContent =_XmlTextReader.Readinnerxml();
        System.IO.File.WriteAllText("C:\users\vaio\desktop\new folder");

but it didn't work**

PS: sorry my English not very well

Try this.

XmlDocument document = new XmlDocument();
document.Load("http://www.w3schools.com/php/links.xml");

File.WriteAllText("c:\\links.xml", document.InnerXml);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM