Waschtel
asked on
How to parse a kml/xml file in Java
Hi,
I'm trying to geocode an address with google maps.
You can look at the kml file I am trying to parse by typing:
http://maps.google.com/maps/geo?q=Hofbrunnstrasse+39,Munich,Germany&output=xml&key=abcdefg
into your browser.
I try to create a DOM document from the kml file returned by the google maps server in Java, but I am encountering problems when there are german "Umlaute (special characters like 'ä,'ö','ü')" in the kml response. Is there any way to parse the kml file differently, so I don't get an exception thrown?
Thanks for any help!
Sebastian.
I'm trying to geocode an address with google maps.
You can look at the kml file I am trying to parse by typing:
http://maps.google.com/maps/geo?q=Hofbrunnstrasse+39,Munich,Germany&output=xml&key=abcdefg
into your browser.
I try to create a DOM document from the kml file returned by the google maps server in Java, but I am encountering problems when there are german "Umlaute (special characters like 'ä,'ö','ü')" in the kml response. Is there any way to parse the kml file differently, so I don't get an exception thrown?
Thanks for any help!
Sebastian.
String question = "http://maps.google.com/maps/geo?q=Hofbrunnstrasse+39,Munich,Germany&output=xml&key=abcdefg"
try {
builder = builderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
try {
// Following line throws an exception of type:
//com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence.
Document document = builder.parse(question);
} catch (SAXException e) {
e.printStackTrace();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.