2014-12-01 4 views
0

http://158.58.185.214/Applications/Operator/Files/Data/Bus/CityList.xml에서 xml 문자열을 읽을 수 없으며 인코딩 문제가 해결 될 수 있다고 생각합니다.url에서 xml을 읽는 방법 C#

 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#.... 
+0

당신이 오류를 포함하는 데 정확히 어떤 문제를 설명하고 사용하는 코드를 제공하십시오. – CathalMF

+1

문제를 재현 할 수 없습니다. * exact * 코드가 제대로 작동합니다. –

+1

xml이 가져오고 있습니다. 이쪽도 문제 없음 – Bunny

답변

-1

문제가에서 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(); 

이를 참조하십시오 https://support.microsoft.com/kb/307643/en-us

+0

으로 인코딩하기가 어렵습니다. 즉 로컬 파일에서 읽을 때입니다. 그는 원격 위치에서 다운로드하려고합니다. – CathalMF

+0

이 오류가 발생합니다. 16 진수 값 0x1F는 잘못된 문자입니다. 라인 1, 위치 1. – Farhood