XPath query of DOM.
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)?
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.
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).
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.
wouldn't it just be possible to fetch these nodes using xPath and then remove them?
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.
Don't wake the dead, please. The last post here was from August 2010, almost one and a half year ago...