I'm trying to alter a .gpx file which contains a link along the lines of:
<?xml version="1.0" encoding="UTF-8"?>
<gpx 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" version="1.1">
<metadata>
<link href="https://example.com/?this=is&an=example">
<text>some text</text>
</link>
</metadata>
</gpx>
After modifying the file using gpxpy and exporting with to_xml(), this turns into:
<?xml version="1.0" encoding="UTF-8"?>
<gpx 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" version="1.1">
<metadata>
<link href="https://example.com/?this=is&an=example">
<text>some text</text>
</link>
</metadata>
</gpx>
which is not valid XML (as even the GitHub markdown highlighting shows) - unlike HTML5, you need to always encode the &. This causes the file to fail to import in gpxpod (and maybe other gpx viewers as well)
I'm trying to alter a .gpx file which contains a link along the lines of:
After modifying the file using
gpxpyand exporting withto_xml(), this turns into:which is not valid XML (as even the GitHub markdown highlighting shows) - unlike HTML5, you need to always encode the
&. This causes the file to fail to import in gpxpod (and maybe other gpx viewers as well)