Hi everyone,
I am using XQuery to grab a node from an XML document, everything works fine up till this point. I don't know what to do next.
Problem description:
I need to grab the attribute and the value from a single node that looks like this
<strong class="class1">0.0376</strong>
<strong class="class1">0.0376</strong>
To copy to clipboard, switch view to plain text mode
to get this node I used
QXmlQuery queryxml;
queryxml.setQuery(xq.arg(query));
QXmlSerializer serializer(queryxml, &buffer);
if (queryxml.isValid()) {
queryxml.evaluateTo(&serializer);
qDebug() << "output: " << output;
}
QString xq = "doc('%1')";
QXmlQuery queryxml;
queryxml.setQuery(xq.arg(query));
QByteArray output;
QBuffer buffer(&output);
buffer.open(QIODevice::WriteOnly);
QXmlSerializer serializer(queryxml, &buffer);
if (queryxml.isValid()) {
queryxml.evaluateTo(&serializer);
qDebug() << "output: " << output;
}
To copy to clipboard, switch view to plain text mode
The reason I need to get the attribute is that class name will sometimes be "class2" and depending on that I need to do different things with the 0.0376 value.
http://doc.trolltech.com/snapshot/qx...odelindex.html suggested to use an XML receiver to get attributes, names and child nodes, so I did that, but have no idea how to proceed and haven't seen any examples of this.
So my question is: How to get the attribute and value of the node using either code above or other code that uses XQuery;
Thanks,
josh
Bookmarks