2012-08-31 53 views
0

我正在解析rss提要從另一臺服務器中進行解析並顯示在Repeater中。 但有錯誤:給定編碼中的字符無效。 的代碼如下:解析RSS提要時給定編碼中的字符無效

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load 
     'Create a WebRequest 
     Dim rssReq As WebRequest = WebRequest.Create("http://www.freelancer.com/rss/affiliatejob_mamboking_NET.xml") 
     'Create a Proxy 
     Dim px As New WebProxy("http://www.freelancer.com/rss/affiliatejob_mamboking_NET.xml", True) 
     'Assign the proxy to the WebRequest 
     rssReq.Proxy = px 
     'Set the timeout in Seconds for the WebRequest 
     rssReq.Timeout = 5000 
     Try 
      'Get the WebResponse 
      Dim rep As WebResponse = rssReq.GetResponse() 
      'Read the Response in a XMLTextReader 
      Dim xtr As New XmlTextReader(rep.GetResponseStream()) 
      'Create a new DataSet 
      Dim ds As New DataSet() 
      'Read the Response into the DataSet 
      ds.ReadXml(xtr) 
      'Bind the Results to the Repeater 
      rssFreelance.DataSource = ds.Tables(0) 
      rssFreelance.DataBind() 
     Catch ex As Exception 
      Throw ex 
     End Try 
    End Sub 

當我看到它的顯示UTF-8編碼的XML的源。

<?xml version="1.0" encoding="utf-8"?> 
<?xml-stylesheet type="text/xsl" href="http://www.freelancer.com/content/rss.xsl" ?><rss version="2.0" xmlns:coop="http://www.google.com/coop/namespace"> 

回答

0
Imports System.Web 
WebUtility.HtmlDecode(response) 

響應是要解碼的實際文本,說明標題

+0

它已經解決了,但無論如何感謝。 –