I want to parse an gpx (xml) document which starts as follows:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx version="1.1" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" creator="Ian">
When parsing I get the follwoing error:
android.sax.BadXmlException: Line 1: Root element name does not match. Expected: 'gpx', Got: 'http://www.topografix.com/GPX/1/1:gpx'
However if I then remove the xmlns="http://www.topografix.com/GPX/1/1" attribute – it parses perfectly.
The code I’m using to parse is android.util.Xml.parse(is,Xml.Encoding.UTF_8,gpx.getContentHandler());
Does anyone know why this attribute is cauing the parse error?
Any help is much appreciated!
Ian
When you create your rootElement, you have an opportunity to specify the namespace…