赞
踩
项目*.pro 里添加
QT += xml
1 写XML : main.cpp
- #include <QtCore>
- #include <QDebug>
- #include <QtXml>
- int main(int argc, char *argv[])
- {
- QCoreApplication a(argc, argv);
- //Write XML
- QDomDocument document;
- //Make the root element
- QDomElement root =document.createElement("Books");
- //Add it to the documnet
- document.appendChild(root);
- //Add some elements
- for(int i =0;i<10;++i)
- {
- QDomElement book = document.createElement("Book");
- book.setAttribute("Name","My Book " +QString::number(i));
- book.setAttribute("ID",QString::number(i));
- root.appendChild(book);
- for(int h=0;h<10;h++)
- {
- QDomElement chapter = document.createElement("Chapter");
- chapter.setAttribute("Name","My Chapter " &#

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。