0

別のサーバーから 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

xml のソースを見ると、utf-8 エンコーディングが表示されます。

<?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">
4

1 に答える 1

0
Imports System.Web
WebUtility.HtmlDecode(response)

responseは、デコードする実際のテキストdescriptionまたはtitleです。

于 2013-02-22T06:35:09.223 に答える