Solved QDomDocument and QPath
-
Is there a way to specify a qpath expression to search a QDomDocument object for a node?
For example, I have some xml like the following:
<config> <section1> <subsection1> <camera name="mycam"> <ip>1.2.3.4</ip> </camera> </subsection1> </section1> </config>
I would like to pass in an xpath like /section1/subsection1/camera[@name="mycam"] and have it return the node which I can update.
-
Hi
You can maybe use
https://doc.qt.io/qt-5/qxmlquery.htmlIs QPath = XPath or did i miss something ?
-
@mrjj Yeah, I meant XPath. We have so many acronyms ;)
-
@Daniel-Williams
From what I can see, it's not like in e.g. MS stuff, you have to some work. See the code in https://stackoverflow.com/questions/56062025/search-for-nodes-in-a-qdomdocument-using-xpath. It's only 5 months ago, so I assume the answer is "current & correct". https://stackoverflow.com/questions/1286842/how-do-i-run-xpath-queries-in-qt looks like more work.As @mrjj said, there's also https://doc.qt.io/qt-5/qxmlquery.html#details, which works with XPath but not with QDomDocument, I think.