Hello,
I created a user control in c#.net to display google maps. In the event that a location is missing a latitude and longitude, I make a call to the google service, which returns xml. I want to load a dataset with this xml data, but I get an error: "Data at root is invalid. Line 1 position 1."
This is the code that I'm using. The error occurs on the second to last line (DS.ReadXml(tx)
This is the xml that is returned from the URL
<?xml version="1.0" encoding="UTF-8" ?><kml xmlns="/kml/2.0"><Response><name>9140 Woodend Road, Edwardsville, KS, 66111</name>
<Status><code>200</code><request>geocode</request></Status><Placemark
id="p1"><address>9140 Woodend Rd, Kansas City, KS 66111, USA</address>
<AddressDetails Accuracy="8"
xmlns="urnasis:names:tc:ciq:xsdschema:xAL:2.0"><Country>
<CountryNameCode>US</CountryNameCode><CountryName>USA</CountryName>
<AdministrativeArea><AdministrativeAreaName>KS</AdministrativeAreaName>
<Locality><LocalityName>Kansas City</LocalityName><Thoroughfare>
<ThoroughfareName>9140 Woodend Rd</ThoroughfareName></Thoroughfare>
<PostalCode><PostalCodeNumber>66111</PostalCodeNumber></PostalCode>
</Locality></AdministrativeArea></Country></AddressDetails><ExtendedData>
<LatLonBox north="39.0542214" south="39.0479262" east="-94.7899011"
west="-94.7961963" /></ExtendedData><Point>
<coordinates>-94.7930487,39.0510738,0</coordinates></Point></Placemark>
</Response></kml>
The xml is well-formed, and if I save it to a file and then load the file, it works. But I need it to be able to read it from the stream, or from the string.
People have mentioned that deleting the vti_cnf folder will fix the problem, but I've already tried that, and it didn't do anything.
I've run out of things on the internet to read. Does anyone have some insight into this, or have an idea for a different solution?
Thanks!
nimarii
I created a user control in c#.net to display google maps. In the event that a location is missing a latitude and longitude, I make a call to the google service, which returns xml. I want to load a dataset with this xml data, but I get an error: "Data at root is invalid. Line 1 position 1."
This is the code that I'm using. The error occurs on the second to last line (DS.ReadXml(tx)
Code:
URL = "[URL unfurl="true"]http://maps.google.com/maps/geo?q="[/URL] + GP.Address +
"&output=xml&key=" + GoogleAPIKey;
HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(URL);
HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse();
string result = "";
Stream response = webresponse.GetResponseStream();
System.IO.StreamReader readStream = new StreamReader(response, System.Text.Encoding.GetEncoding("utf-8"));
result = readStream.ReadToEnd();
StringReader tx = new StringReader(result);
DataSet DS = new DataSet();
//string filename = "testload2.xml";
DS.ReadXml(tx);
readStream.Close();
This is the xml that is returned from the URL
<?xml version="1.0" encoding="UTF-8" ?><kml xmlns="/kml/2.0"><Response><name>9140 Woodend Road, Edwardsville, KS, 66111</name>
<Status><code>200</code><request>geocode</request></Status><Placemark
id="p1"><address>9140 Woodend Rd, Kansas City, KS 66111, USA</address>
<AddressDetails Accuracy="8"
xmlns="urnasis:names:tc:ciq:xsdschema:xAL:2.0"><Country>
<CountryNameCode>US</CountryNameCode><CountryName>USA</CountryName>
<AdministrativeArea><AdministrativeAreaName>KS</AdministrativeAreaName>
<Locality><LocalityName>Kansas City</LocalityName><Thoroughfare>
<ThoroughfareName>9140 Woodend Rd</ThoroughfareName></Thoroughfare>
<PostalCode><PostalCodeNumber>66111</PostalCodeNumber></PostalCode>
</Locality></AdministrativeArea></Country></AddressDetails><ExtendedData>
<LatLonBox north="39.0542214" south="39.0479262" east="-94.7899011"
west="-94.7961963" /></ExtendedData><Point>
<coordinates>-94.7930487,39.0510738,0</coordinates></Point></Placemark>
</Response></kml>
The xml is well-formed, and if I save it to a file and then load the file, it works. But I need it to be able to read it from the stream, or from the string.
People have mentioned that deleting the vti_cnf folder will fix the problem, but I've already tried that, and it didn't do anything.
I've run out of things on the internet to read. Does anyone have some insight into this, or have an idea for a different solution?
Thanks!
nimarii