View Single Post
  #3 (permalink)  
Old 10-04-2008, 9:53 PM
Slowjim Slowjim is offline
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Sep 2008
Location: League City, TX
Age: 62
Posts: 6
Reputation: 0
Slowjim is on a distinguished programming path ahead
Default

Thanks very much for your response.

The error is;
Invalid character in the given encoding. Line 1, position 126.

Below is what is sent;

URL = "http://maps.google.com/maps/geo?q=Hartmannstr+30,Weil+im+Schönbuch,,DE&output= xml&key=" + _
"ABQIAAAAR4h9tcbJyNCgHr0RBAyqDBT2yXp_ZAY8_ufC3CFXh HIE1NvwkxSLYTrTqnjv8HjmG0WWkFrM9nBdOw"

This is the offending code;
The error occurs when strTmp = XmlRdr.ReadString

Code:
       XmlRdr = New XmlTextReader(URL)
        XmlRdr.WhitespaceHandling = WhitespaceHandling.None
        XmlRdr.MoveToContent()

        Do While Not XmlRdr.EOF
            If XmlRdr.Name = "name" Then
                strTmp = XmlRdr.ReadString
            End If
            If XmlRdr.Name = "code" Then
                If Not XmlRdr.ReadString = "200" Then
                    errFlg = True
                    strTmp = String.Concat(strTmp, vbCrLf, vbCrLf, "Address not found!")
                    MsgBox(strTmp, MsgBoxStyle.Exclamation)
                End If
                Exit Do
            End If
            XmlRdr.Read()
        Loop
However, if the below url is sent then it works just fine!

URL = "http://maps.google.com/maps/geo?q=7310+Corsicana,Houston,,US&output=xml&key=" + _
"ABQIAAAAR4h9tcbJyNCgHr0RBAyqDBT2yXp_ZAY8_ufC3CFXh HIE1NvwkxSLYTrTqnjv8HjmG0WWkFrM9nBdOw"

When I use IExplorer and just paste the offending url in it, this is what is returned.
HTML Code:
<?xml version="1.0" encoding="UTF-8" ?>
<kml xmlns="http://earth.google.com/kml/2.0">
  <Response>
    <name>Hartmannstr 30,Weil im Schönbuch,,DE</name>
    <Status>
      <code>200</code>
      <request>geocode</request>
    </Status>
    <Placemark id="p1">
      <address>Hartmannstraße 30, 71093 Weil im Schönbuch, Bundesrepublik Deutschland</address>
      <AddressDetails Accuracy="8" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
        <Country>
          <CountryNameCode>DE</CountryNameCode>
          <AdministrativeArea>
            <AdministrativeAreaName>Baden-Württemberg</AdministrativeAreaName>
            <SubAdministrativeArea>
              <SubAdministrativeAreaName>Böblingen</SubAdministrativeAreaName>
              <Locality>
                <LocalityName>Weil im Schönbuch</LocalityName>
                <Thoroughfare>
                  <ThoroughfareName>Hartmannstraße 30</ThoroughfareName>
                </Thoroughfare>
                <PostalCode>
                  <PostalCodeNumber>71093</PostalCodeNumber>
                </PostalCode>
              </Locality>
            </SubAdministrativeArea>
          </AdministrativeArea>
        </Country>
      </AddressDetails>
      <Point>
        <coordinates>9.056498,48.624399,0</coordinates>
      </Point>
    </Placemark>
  </Response>
</kml>
I am at a loss to explain this. I would greatly appreciate any help.

Last edited by Slowjim; 10-05-2008 at 7:42 AM.
Reply With Quote