有什么方法可以删除 KML 文件中额外的命名空间前缀(即 ns2)?
这是我从代码中收到的 kml 示例:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:kml xmlns="http://www.google.com/kml/ext/2.2" xmlns:ns2="http://www.opengis.net/kml/2.2" xmlns:ns3="http://www.w3.org/2005/Atom" xmlns:ns4="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
<ns2:Placemark>
<ns2:name>London, UK</ns2:name>
<ns2:open>1</ns2:open>
<ns2:Point>
<ns2:coordinates>-0.126236,51.500152</ns2:coordinates>
</ns2:Point>
</ns2:Placemark>
</ns2:kml>
我想要的是这样的:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Placemark>
<name>London, UK</name>
<open>true</open>
<Point>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>-0.126236,51.500152</coordinates>
</Point>
</Placemark>
</kml>
这是我的java代码:
final Kml kml = new Kml();
kml.createAndSetPlacemark()
.withName("London, UK").withOpen(Boolean.TRUE)
.createAndSetPoint().addToCoordinates(-0.126236, 51.500152);
//marshals to console
kml.marshal();
//marshals into file
kml.marshal(new File("output.kml"));
任何帮助深表感谢!谢谢!