Avatar of bkourouma
bkourouma

asked on 

Invalid character in the given encoding. Error

Hello,

I have the following error:
Invalid character in the given encoding. Line 25, position 114.

I am using Asp.net Vb.net  with the code below:

  <div>
        <asp:GridView ID="GridView1" runat="server" DataSourceID="XmlDataSource1">
        </asp:GridView>
        <asp:XmlDataSource ID="XmlDataSource1" runat="server"
            DataFile="http://www.meteorologic.net/webmaster/xml/xml_file_4330.xmlhttp://www.meteorologic.net/webmaster/xml/xml_file_4330.xml">
        </asp:XmlDataSource>
    </div>

I read here that this might be because of encoding to utf-8.

I changed the webconfig as follows:
  <globalization
              fileEncoding="utf-8"
              requestEncoding="utf-8"
              responseEncoding="utf-8"
          />

But still get the same error. Please help

Web Languages and StandardsASP.NETWeb Applications

Avatar of undefined
Last Comment
bkourouma
ASKER CERTIFIED SOLUTION
Avatar of Kelvin McDaniel
Kelvin McDaniel
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Watch out for those two lines that got wrapped; both pertain to Me.lblStatus.Text and should be only one line each.
SOLUTION
Avatar of ajitha75
ajitha75
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of bkourouma
bkourouma

ASKER

ajitha75, Great tip!  I was able to read but I still had binaries in lieu of the french accents.

I used this fonction:
 Public Function ProcessRSSItem(ByVal rssURL As String) As String

        'Definition de la valeur par défaut de retour
        ProcessRSSItem = "Serveur injoignable!"

        'test de la connexion au serveur xml
        Dim instance As New Devices.Network
        'Dim address As Uri
        Dim returnValue As Boolean = True
        'Try
        '    returnValue = instance.Ping(url)
        'Catch ex As Exception
        '    MsgBox(ex.Message)
        'End Try


        'Tentative de résolution de l'affichage aléatoire des flux RSS
        'Dim returnValue As Boolean = False
        'Try
        '    returnValue = instance.Ping(url)
        'Catch ex As Exception
        '    MsgBox(ex.Message)
        'End Try

        If returnValue Then
            Try
                ProcessRSSItem = ""
                Dim myRequest As WebRequest = System.Net.WebRequest.Create(rssURL)
                Dim myResponse As WebResponse = myRequest.GetResponse()

                Dim rssStream As Stream = myResponse.GetResponseStream()
                Dim rssDoc As New XmlDocument()
                rssDoc.Load(rssStream)

                Dim rssItems As XmlNodeList = rssDoc.SelectNodes("rss/channel/item")

                Dim title As String = ""
                Dim link As String = ""
                Dim description As String = ""
                Dim i As Integer

                For i = 0 To rssItems.Count - 1
                    Dim rssDetail As XmlNode

                    rssDetail = rssItems.Item(i).SelectSingleNode("title")
                    If rssDetail.Equals(Nothing) = False Then
                        title = rssDetail.InnerText
                    Else
                        title = ""
                    End If

                    rssDetail = rssItems.Item(i).SelectSingleNode("link")
                    If rssDetail.Equals(Nothing) = False Then
                        link = rssDetail.InnerText
                    Else
                        link = ""
                    End If

                    rssDetail = rssItems.Item(i).SelectSingleNode("description")
                    If rssDetail.Equals(Nothing) = False Then
                        description = rssDetail.InnerText
                    Else
                        description = ""
                    End If

                    ProcessRSSItem += "" + title + ""
                    ProcessRSSItem += description + ""

                Next
            Catch ex As Exception
                ProcessRSSItem += "Le serveur est injoignable. Veuillez vérifier votre connexion internet !"
            End Try
        End If

    End Function

And it worked great.

ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo