[英]How to read xml from url C#
我無法從http://158.58.185.214/Applications/Operator/Files/Data/Bus/CityList.xml
讀取xml字符串,我認為編碼是個問題,請幫助解決。
我的代碼是:
string url = "http://158.58.185.214/Applications/Operator/Files/Data/Bus/CityList.xml";
WebClient client = new WebClient();
string xml = client.DownloadString(url);
但xml字符串是:
‹ í½`I–%&/mÊ{JõJ×àt¡€`$Ø@ìÁˆÍæ’ìiG#....
您的問題可以這樣解決
使用System.Xml;
String URLString = " http://localhost/books.xml";
XmlTextReader reader = new XmlTextReader (URLString);
while (reader.Read())
{
// Do some work here on the data.
Console.WriteLine(reader.Name);
}
Console.ReadLine();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.