遍历xml
递归遍历xml节点
void TravelXmlNode(QDomElement & element) { QDomNode node = element.firstChild(); while (!node.isNull()) { QDomElement childElement = node.toElement(); // try to convert the node to an element. if (!childElement.isNull()) { QString objId = childElement.attribute("ID"); QString parentId = childElement.attribute("ParentID"); QString name = childElement.attribute("Name"); QString itemIcon = childElement.attribute("ItemIcon"); QString tagName = childElement.tagName(); if (tagName == "Folder") { TravelXmlNode(childElement); } else if (tagName == "Object") { TDObject* tdObj = SceneManage::getInstall()->getNode(objId.toStdString()); } } node = node.nextSibling(); } }
这是我自己的情况,别人如果要用,酌情修改。