Click here to Skip to main content
14,491,951 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,

I am trying to converting an address to lat and lng.
This is what I used but I'm getting this error

public void GetCoOrdinates()
        {
            string serviceUri = string.Format("http://rpc.geocoder.us/service/rest?address={0},{1},{2}", street, city, state);
            XmlDocument serviceXmlDoc = new XmlDocument();
            serviceXmlDoc.Load(serviceUri);
            XmlNamespaceManager geoCoderManager = new XmlNamespaceManager(serviceXmlDoc.NameTable);
            geoCoderManager.AddNamespace("geoCoderService", @"http://www.w3.org/2003/01/geo/wgs84_pos#");
            string longitude = serviceXmlDoc.DocumentElement.SelectSingleNode(@"//geoCoderService:long", geoCoderManager).InnerText;
            string latitude = serviceXmlDoc.DocumentElement.SelectSingleNode(@"//geoCoderService:lat", geoCoderManager).InnerText;
            MessageBox.Show(String.Format("Latitude: {0} Latitude: {1}", latitude, longitude));
        }

ERROR: Data at the root level is invalid. Line 1, position 1
Posted
Updated 14-Mar-12 3:26am
v2
Comments
BobJanova 14-Mar-12 9:30am
   
Are you sure you're submitting the service request in the right format? Check the service provider's documentation and examples.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You're goingo to have to contact GeoCoder on this one. We have no idea what their service requires.

Also, you do know that you're never going to get a completely accurate location for any given IP, correct?? You could get a result that's off by upwards of 100 miles.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100