首页 > 其他分享 >遍历xml

遍历xml

时间:2023-07-31 10:22:24浏览次数:31  
标签:xml node 遍历 childElement attribute QString tagName

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

}

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

标签:xml,node,遍历,childElement,attribute,QString,tagName
From: https://www.cnblogs.com/warmlight/p/17394278.html

相关文章

  • 19_Spring_事务管理XML配置方式
    19_Spring_事务管理XML配置方式applicationContext中,通过AOP实现事务的控制<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/sche......
  • 20_Spring_零XML事务控制
    20_Spring_零XML事务控制创建配置类packagecom.msb.config;importcom.alibaba.druid.pool.DruidDataSource;importorg.springframework.beans.factory.annotation.Value;importorg.springframework.context.annotation.Bean;importorg.springframework.context.annot......
  • 4_Spring_XML方式实现DI
    4_Spring_XML方式实现DIspring中的Bean的管理:Bean(汉译咖啡豆).又称JAVABean.其实就是JAVA程序程序中的一个个对象,所以Bean的管理其实就是spring对于JAVA程序中的对象的管理管理的内容是什么1对象的创建 IOCIOC 叫做控制反转,就是Spring给我们创建对象,然后我们直......
  • 13_Spring_AOPXML方式实现_了解
    13_Spring_AOPXML方式实现_了解1、创建两个类,增强类和被增强类,创建方法见之前的代码2、在spring配置文件中创建两个类对象 3、在spring配置文件中配置切入点<aop:config><!--切入点--><aop:pointcutid="pointCutAdd"expression="execution......
  • 不启动SpringBootApplication 直接测试mybatis 下面xml中的sql
     测试类 privatestaticSqlSessionsqlSession=null;privatestaticRunoobTblMappermapper; @BeforeClasspublicstaticvoidsetUpMybatisDatabase()throwsIOException{InputStreamresourceAsStream=null;try{ClassLoaderclassLoader=R......
  • SAP Fiori Elements 应用 metadata.xml 解析成的 JSON 对象
    在这个文件设置断点: AnnotationParser._parserData.metadataProperties=AnnotationParser.getAllPropertiesMetadata(AnnotationParser._parserData.serviceMetadata); if(AnnotationParser._parserData.metadataProperties.extensions){ mappingList.propertyExtensi......
  • SAP Fiori Elements 本地 annotation.xml 里的一个代码片段
    下面是从SAPUI5FioriElements应用本地注解文件摘录出来的xml片段,这些代码的含义是:<AnnotationsTarget="SEPMRA_PROD_MAN.SEPMRA_PROD_MAN_Entities/SEPMRA_C_PD_Product"xmlns="http://docs.oasis-open.org/odata/ns/edm"><AnnotationTerm=&......
  • AJAX--XMLHttpRequest对象
    一、了解XMLHttpRequest对象是AJAX的核心对象,发送对象以及接收服务器数据的返回XMLHttpRequest对象浏览器都内置了该对象,直接使用二、XMLHttpRequest对象的方法和属性1、创建XMLHttpRequest对象varxhr=newXMLHttpRequest()2、XMLHttpRequest对象的方法方法描述......
  • 二叉树的广度优先遍历
    二叉树的广度优先遍历层序遍历设二叉树的根节点所在层数为第一层,层序遍历就是从二叉树的根节点出发,先访问第一层的根节点,然后从左到右访问第2层上的节点,以此类推,自上而下,自左至右逐层访问树的结点的过程就是层序遍历。要想用代码实现队列的层序遍历我们需要借助队列:1、先把根......
  • AJAX - 创建 XMLHttpRequest 对象
      AJAX-创建XMLHttpRequest对象AJAX(异步JavaScript和XML)是一种在Web应用程序中创建快速动态更新的技术。使用AJAX,Web应用程序可以异步地向服务器发送和接收数据,而无需刷新整个页面。AJAX广泛用于Web应用程序中,包括社交媒体,电子商务,在线游戏等等。XMLHttpRequest是A......