QML XmlListModel 和 car2go xml 解析
我无法解析 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()”等。
提前致谢
I fail to parse car2go responses in qml xmllistmodel.
<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>
and my code is
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()" }
}
But i do get
Error XPST0003 in file ... syntax error, unexpected NCName, expecting ;
QML XmlRole: invalid query: "name/string()" etc.
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第二个命名空间声明缺少终止分号。
替换
为
应该可以修复它。
The second namespace declaration is missing a terminating semicolon.
Replacing
with
should fix it.