问题描述
- poco中读写xml,如何去获取一个element
-
最近在利用poco库去读写xml文件,现在遇到一个问题,在读一个xml文件的时候,如何去获取xml中的一个element呢?
在QT中,有处理xml文件的相关函数,例如://检查Iteration是否存在 QDomElement inter; bool bIterExist = false; QDomNodeList interList = root.childNodes(); for(int i = 0; i < (int)interList.count(); i++) { if(stInter.nId == interList.item(i).toElement().attributeNode("ID").value().toInt()) { inter = interList.item(i).toElement(); bIterExist = true; break; } } if(!bIterExist) { inter = doc.createElement(QObject::tr("Interation")); inter.setAttribute(QObject::tr("ID"), stInter.nId); }
QT 就想上面那样去获取一个想要的element,我想把这段代码改为poco库写的,应该如何去写,就是如何用poco实现这句代码:
inter = interList.item(i).toElement();
解决方案
时间: 2024-09-10 21:10:27