Converting QXmlItem to QtDomElement or similar?
- by EightyEight
Hello everyone.
I'm parsing a fairly complicated XML file of the following structure:
<root> ... ... <item> <subitem id="1"/> <text> text1 </text> </item> <item> <subitem id="2"/> <text> text2 </text> </item> ... <item> ... </item> ...</root>
It's pretty crude but you get my drift I hope. I'm primarily interested in "item" nodes. So I wrote the following code (directly out of the Qt's online manual):
QXmlQuery query;
query.setQuery("//item/");
QXmlResultItems result;
query.evaluateTo(&result);
QXmlItem item(result.next());
while (!item.isNull())
{
if (item.isNode())
{
// WHAT DO I DO NOW?
}
item = result.next();
}
Now, QXmlItem appears to represent two concepts, a literal value (like a string) or a Node, (which is what item.isNode() is doing). Unfortunately, I can't grasp how to convert the QXmlItem to something that will query-able again. In particular from the example above I'd like to grab the "id" attribute, and the text element. Can I do this using the XQuery approach, or am I way off base here?
Any advice?
Thanks!