1

我正在做vb.net 项目,我已经创建了动态新闻 tiker。

代码 :

Imports System.ServiceModel.Syndication
Imports System.Xml

Partial Class DynamicTicker
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Get the latest syndicated content from my Twitter feed!
        Dim myTweets As SyndicationFeed = SyndicationFeed.Load(XmlReader.Create("https://twitter.com/ashuthinks"))

        'Bind myTweets to the ListView
        lvTweets.DataSource = myTweets.Items
        lvTweets.DataBind()
    End Sub

    Protected Function FormatSummary(ByVal summary As String) As String
        Const SummaryHeader As String = "ScottOnWriting: "

        'Remove the leading "ScottOnWriting: "
        If summary.StartsWith(SummaryHeader) Then
            Return summary.Substring(SummaryHeader.Length)
        End If
    End Function

    Protected Function FormatPubDate(ByVal pubDate As DateTime) As String
        Return pubDate.ToString("h:mm, MMM d")
    End Function

End Class

但这给了我和以下错误:

出于安全原因,此 XML 文档中禁止使用 DTD。要启用 DTD 处理,请将 XmlReaderSettings 上的 DtdProcessing 属性设置为 Parse 并将设置传递给 XmlReader.Create 方法。

我应该在我的代码中在哪里提到设置?

4

2 回答 2

0
Dim settings As XmlReaderSettings = new XmlReaderSettings()
settings.DtdProcessing = DtdProcessing.Parse;
Dim myTweets As SyndicationFeed =     SyndicationFeed.Load(XmlReader.Create("https://twitter.com/ashuthinks"),settings)

抱歉,如果我的语法不正确,请不要编写太多 VB.NET 代码。

于 2013-09-09T13:31:22.933 回答
0
Dim settings As New XmlReaderSettings
   settings.DtdProcessing = DtdProcessing.Parse
   settings.ValidationType = ValidationType.DTD
   Dim xmlR = XmlReader.Create(Currentfile, settings)
于 2020-05-08T06:39:17.880 回答