locked
Invalid character in the given encoding - xml feed RRS feed

  • Question

  • User-228717300 posted

    i'm getting an error message "Invalid character in the given encoding" when running while loop - reading xml feed (Google Maps GeoCoding). I think i have everything in place - encoding UTF-8 in webconfig file and in the page directive. When running US location everthing is fine but when running for example German locations for instance Munich - im getting an error. So i am gussing this must be related to encoding. What else can i do unsure UTF-8 encoding.

     Please Advice

     UTF-8 webconfig - <globalization requestEncoding="utf-8"
    responseEncoding="utf-8"/>

    page directive <%@ Page Language="VB" MasterPageFile="~/Pol.master"
    AutoEventWireup="false" ResponseEncoding="utf-8" %>

    code:

            Dim strQuery As String = ("http://maps.google.com/maps/geo?q="
    & TextBox1.Text &
    "&output=xml&key=ABQIAAAAI5xuh8RFbMdW3Cjzb89dzhSekc5PrxCB5hpn03imGOIm7xkIUh­Q76p25PwErDDSp58Zxha-
    t79UV4Q")

            Dim objXMLReader As New XmlTextReader(strQuery)

            DisplayXML(objXMLReader)
            objXMLReader.Close()

     Private Sub DisplayXML(ByVal xmlReader As XmlTextReader)

            While xmlReader.Read()

                If xmlReader.NodeType = XmlNodeType.Element Then
                    Response.Write("<br>")

                    Response.Write("<b>Element: </b>" + xmlReader.Name)
                    Name = xmlReader.Name
                    If xmlReader.HasAttributes Then
                        Response.Write(" <b>Attributes: </b>")
                        For attIdx As Integer = 0 To
    xmlReader.AttributeCount - 1


                            Response.Write(xmlReader(attIdx))

                           If attIdx < xmlReader.AttributeCount - 1 Then
                                Response.Write(", ")
                            End If
                        Next
                    End If

                ElseIf xmlReader.NodeType = XmlNodeType.Text Then

                    Response.Write(" <b>Value: </b>" + xmlReader.Value)

                End If

            End While

        End Sub

    Friday, April 25, 2008 12:03 PM

Answers

  • User-2115483147 posted

    i'm getting an error message "Invalid character in the given encoding" when running while loop - reading xml feed (Google Maps GeoCoding). I think i have everything in place - encoding UTF-8 in webconfig file and in the page directive. When running US location everthing is fine but when running for example German locations for instance Munich - im getting an error. So i am gussing this must be related to encoding. What else can i do unsure UTF-8 encoding.

     

    Hi gunter,

    Sorry that I am not familiar with this area.

    After hard search, I found an article called "ERR: Invalid character in the given encoding. Line 7, position 15 is displayed when logging into WebDir", and see the following paragraph:

    To work around the issue, save the strings.xml file using Encoding format UTF-8, which does support foreign characters for XML format files. 

    and see the original link:

    http://community.imanami.com/forums/thread/329.aspx

    Hope it helps,

    Hong Gang

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 30, 2008 1:43 AM