how can i load the contents of an xml file at a url into a string?
how can i load the contents of an xml file at a url in开发者_运维百科to a string?
eg there is an xml file at http://www.example.com/test.xml
I want the text of the xml to be assigned to a string. How can i do that using c#?
thanks
Well, it seems to me that the fact it's XML is irrelevant - just download it as a string:
WebClient client = new WebClient();
string text = client.DownloadString(url);
Other way to get the xml file is through HttpRequest, then you can parse the XML, if that's what you need: previous question on the matter (with code sample)
精彩评论