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();
  • 相关阅读:
    php
    php数据排序---array_multisort
    IOS 线程描述
    IOS 进程描述
    IOS 强指针(strong)和弱指针(weak)
    IOS autosizing(设置控件的固定位置大小)
    IOS UIActivityIndicatorView动画
    IOS UIImageView的帧动画
    IOS Block动画
    IOS UIView动画(封装动画)
  • 原文地址:https://www.cnblogs.com/zhangxuan/p/5726366.html
Copyright © 2011-2022 走看看