zoukankan      html  css  js  c++  java
  • Qt修改xml文件

    <taskpackage styleId="styles/2dc70235-e48b-4e11-b074-3c3f773ae1f3" id="3333" type="normal">
        <playvideo isFlash="false">
            <group times="5618" filename="groupList" playTimes="15" startTime="00:00:00">
                <item filename="COM.mp4" filesize="1.92GB" href="resource/daab3.mp4" flv="resource/aab3.mp4"/>
            </group>
        </playvideo>
        <text>欢迎</text>
    </taskpackage>

    修改id的值。

        QFile file("we.xml");
        QDomDocument doc;
    
    
        if(!file.open(QIODevice::ReadOnly))
        {
            qDebug()<<"xxx";
        }
        if(!doc.setContent(&file))
        {
            file.close();
            qDebug()<<"ttttt";
        }
        file.close();
    
    
    
    
        QDomNode old_node = doc.firstChild();
    
    
        qDebug()<<doc.firstChild().toElement().attribute("id");
    
    
        doc.firstChild().toElement().setAttribute("id", "3333");
        qDebug()<<doc.firstChild().toElement().attribute("id")<<"   "<<doc.firstChild().toElement().attribute("startTime");
        QDomNode new_node = doc.firstChild();
        doc.replaceChild(new_node, old_node);
    
    
        QFile afile("we.xml");
        afile.open(QIODevice::WriteOnly|QIODevice::Truncate);
        QTextStream out(&afile);
        doc.save(out,4);
        afile.close();
  • 相关阅读:
    h5移动开发css
    js 小数相加异常
    h5上滑刷新(分页)
    js中的 !!
    图片懒加载(延迟加载)原理及实现
    作用域内优先级及this指针
    函数的属性、方法和构造函数
    判断是否为严格模式
    匿名函数递归调用自身
    闭包
  • 原文地址:https://www.cnblogs.com/zhangxuan/p/5726366.html
Copyright © 2011-2022 走看看