Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
XPath query of DOM.
Matt last edited by
Are there any plans to support XPath querying of QDomDocument?
I believe it would be useful if it was possible to query a (or part of a) QDomDocument and get a QDomElementList. This could make querying a parsed QDomDocument much easer and may allow us to more easily edit the XML based upon XPath results.
Can anyone suggest an easy way to change the XML based on an XPath (specifically I want to remove elements that match an XPath)?
andre last edited by
Don't count on it. I understand from comments by Thiago on the mailinglist, that the DOM classes are considdered EOL. Grave bugs are fixed, but other than that, they don't get much attention.
david.boddie last edited by
I think it's interesting to look at using XQuery for general XML handling. I started to explore this in my last Qt Quarterly article, "Checking the Weather with XQuery":http://qt.nokia.com/developer/qtquarterly/checking-the-weather-with-xquery, and I'll be writing a follow-up article that looks at visualizing queries for the next issue of QQ (due later this month).
Matt last edited by
Excellent article David, I look forward to reading the next issue.
I have managed to achieve what I wanted using an "XSLT identity transform":http://en.wikipedia.org/wiki/Identity_transform#Example_using_XSLT.
Guest last edited by
wouldn't it just be possible to fetch these nodes using xPath and then remove them?
texas last edited by
One possible way, not saying it's good, is to have all your QDomElements in the DOM be hashed with an xmlid. Then you can use a QXmlSerializer receiver and query for the xmlid's of the elements you want. Then you can get your list of elements via the id hash.
goetz last edited by
Don't wake the dead, please. The last post here was from August 2010, almost one and a half year ago...