<taskpackage styleId="styles/2dc70235-e48b-4e11-b074-3c3f773ae1f3" />
        </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();

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-04-28
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2021-11-13
相关资源
相似解决方案