0
我收到以下錯誤:十六進制值0x1F的,是無效字符
「」,十六進制值0x1F的,是無效字符
這裏是我的功能。我第一次遇到「reader.MoveToContent()」時出現此錯誤。任何人都可以將我指向正確的方向嗎?
Public Function GetSyndicationFeedData(ByVal urlFeedLocation As String) As SyndicationFeed
Dim settings As New XmlReaderSettings() With { _
.IgnoreWhitespace = True, _
.CheckCharacters = True, _
.CloseInput = True, _
.IgnoreComments = True, _
.IgnoreProcessingInstructions = True _
}
If [String].IsNullOrEmpty(urlFeedLocation) Then
Return Nothing
End If
Using reader As XmlReader = XmlReader.Create(urlFeedLocation, settings)
If reader.ReadState = ReadState.Initial Then
reader.MoveToContent()
End If
' Now try reading...
Dim atom As New Atom10FeedFormatter()
Dim rss20 As New Rss20FeedFormatter()
' Atom
If atom.CanRead(reader) Then
atom.ReadFrom(reader)
Return atom.Feed
'Rss 2.0
ElseIf rss20.CanRead(reader) Then
rss20.ReadFrom(reader)
Return rss20.Feed
Else
Return Nothing
End If
End Using
End Function
您是否檢查了Feed以確保它是有效的XML文檔? – Kane
我沒有檢查http://validator.w3.org上的提要,它是有效的。據我瞭解,0x1f是一個Windows控制字符。有些人建議使用替換((char)(0x1F),''),但我不知道如何在這裏實現... –