[英]How to read xml from url C#
I can't read xml string from http://158.58.185.214/Applications/Operator/Files/Data/Bus/CityList.xml
and i think the encoding is the problem please help to solve it. 我无法从
http://158.58.185.214/Applications/Operator/Files/Data/Bus/CityList.xml
读取xml字符串,我认为编码是个问题,请帮助解决。
my code is: 我的代码是:
string url = "http://158.58.185.214/Applications/Operator/Files/Data/Bus/CityList.xml";
WebClient client = new WebClient();
string xml = client.DownloadString(url);
but the xml string is: 但xml字符串是:
‹ í½`I–%&/mÊ{JõJ×àt¡€`$Ø@ìÁˆÍæ’ìiG#....
your problem can be solve like this 您的问题可以这样解决
using System.Xml; 使用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();
refer this: https://support.microsoft.com/kb/307643/en-us 请参阅此: https : //support.microsoft.com/kb/307643/en-us
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.