1
votes

I'm working on vb.net project and i have created dynamic news tiker.

code :

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

But this is giving me and following error :

For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.

where should I mention setting in my code?

2
Did you try doing what the exception text recommended? Or are you having trouble understanding the message? I don't know anything specifically about that exception, but that's the first thing I would try. - Steven Doggart
I'm having trouble to set the XmlReaderSettings in my vb.net code - Neo
Have you looked at the example in the MSDN? msdn.microsoft.com/en-us/library/ms162474.aspx - Steven Doggart

2 Answers

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

Sorry if my syntax is off, don't write much VB.NET code.

0
votes
Dim settings As New XmlReaderSettings
   settings.DtdProcessing = DtdProcessing.Parse
   settings.ValidationType = ValidationType.DTD
   Dim xmlR = XmlReader.Create(Currentfile, settings)