[Qt-interest] How xpath query xml QDomDocument ? "/bookstore/book[price>28]/title"

Ed Sutton edsutton at gmail.com
Mon Aug 17 17:47:56 CEST 2009


I am seeking something similar to Microsoft's
XmlNode::SelectSingleNode method that supports xpath queries.  When I
search Qt help the solution appears to be QXmlQuery.  The xmlpatterns
examples are challenging to get started with.

Given the sample xml file pasted below, how do I xml query for books
over $28 dollarr, for example, /bookstore/book[price>28]/title ?

QDomDocument* pDomDocument = OpenConfigFile("configuration.xml");

// How implement query for /bookstore/book[price>28]/title
QXmlQuery query;

...
???

<bookstore>

<book category="COOKING">
  <title lang="en">Everyday Italian</title>
  <author>Giada De Laurentiis</author>
  <year>2005</year>
  <price>30.00</price>
</book>

<book category="CHILDREN">
  <title lang="en">Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

</bookstore>


Thanks in advance,

-Ed



More information about the Qt-interest-old mailing list