locked
XMLException RRS feed

  • Question

  • Getting an Exception that I'm hoping that someone can help me resolve.

    Exception - '"' is an unexpected token. Expecting white space. Line 1, position 63

    Exception occurs when the following is run in my project -

        Public Shared Function ProcessNewsFeed(ByVal rssUrl As String) As ArrayList  
            'Request to get Response of RSS feed  
            Dim myRequest As SystemSystem.Net.WebRequest = System.Net.WebRequest.Create(rssUrl)  
            Dim myResponse As System.Net.WebResponse = myRequest.GetResponse()  
     
            'Take Response and stream it  
            Dim rssStream As System.IO.Stream = myResponse.GetResponseStream()  
     
            'Create XML Doc and load it with the RSSStream   
            Dim rssDoc As System.Xml.XmlDocument = New System.Xml.XmlDocument()  
            rssDoc.Load(rssStream) 

    Specifically the error occurs when the rssDoc.Load(rssStream) is run.

    Any suggestions are greatly appreciated.

    Thursday, December 25, 2008 5:26 AM

Answers

All replies

  • Hi,
    probably the XML document contains a " special character which is not supported and should be replaced with the corresponding symbol quot as better shown in this list:

    http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

    Hope this helps
    Alessandro Del Sole - Microsoft MVP http://community.visual-basic.it/Alessandro
    • Marked as answer by Xingwei Hu Wednesday, December 31, 2008 2:24 AM
    Thursday, December 25, 2008 11:49 AM
  • Thanks Alessandro.

    I added the following to my code which appears to have resolved the problem.

                    titletitle = title.Replace("amp", "")  
                    titletitle = title.Replace("lt", "")  
                    titletitle = title.Replace("gt", "")  
                    titletitle = title.Replace("apos", "")  
                    titletitle = title.Replace("quot", "")  
                    descriptiondescription = description.Replace("amp", "")  
                    descriptiondescription = description.Replace("lt", "")  
                    descriptiondescription = description.Replace("gt", "")  
                    descriptiondescription = description.Replace("apos", "")  
                    descriptiondescription = description.Replace("quot", "")  
                    linklink = link.Replace("amp", "")  
                    linklink = link.Replace("lt", "")  
                    linklink = link.Replace("gt", "")  
                    linklink = link.Replace("apos", "")  
                    linklink = link.Replace("quot", "") 

    Although now I'm getting another SyntaxErrorException (Missing operand after 's' operator) when attempting to filter to avoid duplication in my DataSet.

                    Dim filterExpression As String  
                    filterExpression = "Title = '" & title & "'"  
                    'filterExpression = "Title = ' & Title.ToString()" 
     
                    Dim filteredNewsItems() As System.Data.DataRow  
                    filteredNewsItems = myRSSDataSet.NewsItem.Select(filterExpression)  
     
    Monday, January 5, 2009 5:17 AM