遍历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();
    }

}

这是我自己的情况,别人如果要用,酌情修改。

posted @ 2023-07-31 10:13  阳光下的小土豆  阅读(34)  评论(0编辑  收藏  举报