I would think you just need to add the namespace declarations to the FeatureCollection
element, so it looks like this:
<ogr:FeatureCollection
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
You can assumedly do that in your sed script.
When trying to query namespaced elements with xpath you need to register your namespaces first. So you might need to do something like this:
xmlXPathRegisterNs(context, "ogr", "http://ogr.maptools.org/")
xmlXPathRegisterNs(context, "gml", "http://www.opengis.net/gml")
Then when you're trying to query a gml or ogr element, you would do so like this:
xpath = "//gml:coordinates/text()";
xmlXPathEvalExpression(xpath, context);