<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();

 

posted on 2016-08-01 16:42  邶风  阅读(2623)  评论(0编辑  收藏  举报