How do I use foreach with QDomNodeList in Qt?

感情迁移 提交于 2019-12-04 01:33:18

foreach only supports the container classes, so you cannot use it with a QDomNodeList.

I'm not sure of you actual goal, but I find the QXmlSimpleReader and QXmlStreamReader to be the easiest way to deal with XML.

Edit to match question edit:

What you are trying to do looks like a prime candidate for XPath or XQuery. Take a look at the QtXmlPatterns module this will give you a set of character nodes without having to loop through all the other nodes.

foreach works with Qt Generic Containers. It doesn't look like QDomNodeList inherits from anything, so you can't use foreach.

Could you iterate through the node list and insert the nodes into a QList<QDomElement>?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!