我无法在qml xmllistmodel中解析car2go响应。
<kml xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns2="http://www.w3.org/2005/Atom"
xmlns="http://www.opengis.net/kml/2.2">
<Document>
<description>Available CAR2GO Vehicles</description>
<Style id="car2go">
<IconStyle>
<Icon>
<href>http://www.car2go.com/default/img/backgrounds/Marker_car2go.png
</href>
</Icon>
<hotSpot y="0.0" x="0.0" />
</IconStyle>
</Style>
<Placemark>
<name>UL-C5887</name>
<description>Sudetenweg, 89075 Ulm<br/>Fuel
24<br/>Interior EXCELLENT<br/>Exterior EXCELLENT
</description>
<styleUrl>#car2go</styleUrl>
<ExtendedData>
<Data name="fuel">
<value>24</value>
</Data>
<Data name="interior">
<value>EXCELLENT</value>
</Data>
<Data name="exterior">
<value>EXCELLENT</value>
</Data>
<Data name="vin">
<value>WME4513001K154655</value>
</Data>
</ExtendedData>
<Point>
<coordinates>10.029,48.4362,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
我的代码是
XmlListModel {
namespaceDeclarations: "declare namespace ns2='http://www.w3.org/2005/Atom';declare default element namespace 'http://www.opengis.net/kml/2.2'"
query: "/kml/Document/Placemark"
XmlRole { name: "plate_number"; query: "name/string()" }
XmlRole { name: "address"; query: "description/string()" }
XmlRole { name: "fuel"; query: "ExtendedData/Data[1]/string()" }
XmlRole { name: "interior"; query: "ExtendedData/Data[2]/string()" }
XmlRole { name: "exterior"; query: "ExtendedData/Data[3]/string()" }
XmlRole { name: "vin"; query: "ExtendedData/Data[4]/string()" }
XmlRole { name: "coordinates"; query: "coordinates/string()" }
}
但我确实得到了
文件中的错误XPST0003 ...语法错误,意外的NCName,期待; QML XmlRole:无效查询:“name / string()”等。
提前致谢
答案 0 :(得分:1)
第二个名称空间声明缺少终止分号。
更换
namespaceDeclarations: "declare namespace ns2='http://www.w3.org/2005/Atom';declare default element namespace 'http://www.opengis.net/kml/2.2'"
与
namespaceDeclarations: "declare namespace ns2='http://www.w3.org/2005/Atom';declare default element namespace 'http://www.opengis.net/kml/2.2';"
应该修复它。