QXmlQuery setquery for kml file
What should be the query to get the coordinates in the kml file?
kml is XML as far as I know. So, you can open it in a text editor and see how/where coordinates are stored and then define the query.
Yes it is XML Structure, All coordinates can be found between <coordinates> and </coordinates> with a Long/Lat pair in each line.
This might be interersting to read
it seems your sample has coordinates under LineString
so something like
I had checked that link before posting but I didn’ understand how the query args are written and it didn't work for my file. So I want to know how the args are written?
query.setQuery("declare default element namespace \"http://earth.google.com/kml/2.0\"; declare variable $kmlFile external; doc($kmlFile)/kml/Document/Placemark[last()]/LineString/coordinates/text()");
Why dis doesn't work?
what is that ?
and you should check with
qDebug() << result;
what you get.
-how the args are written?
Sorry. Dont understand what u mean with that.
The result gives me "\n".
I meant that for any xml file, by knowing the tags and the values you want to access, how to write a query.
is this part necessary in the query
"declare default element namespace \"http://earth.google.com/kml/2.0\"; declare variable $kmlFile external;
or I can start the query with doc($kmlFile)/kml where $kmlFile is the filename
Ok, so u are getting close. :)
From what I have understood I have made this query.
QXmlQuery query; query.bindVariable("kmlFile", &file); QString q = "declare variable $kmlFile external;doc($kmlFile)/kml/Document/Placemark/LineString/coordinates/text()"; query.setQuery(q);
But I still get the result value as "\n"