This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mainwindow.h" | |
#include "ui_mainwindow.h" | |
#include <QDebug> | |
#include <QFile> | |
#include <QXmlStreamWriter> | |
MainWindow::MainWindow(QWidget *parent) : | |
QMainWindow(parent), | |
ui(new Ui::MainWindow) | |
{ | |
ui->setupUi(this); | |
QFile file("D:\\soft\\pleiades\\xampp\\htdocs\\www\\test.xml"); | |
file.open(QIODevice::WriteOnly | QIODevice::Text); | |
QXmlStreamWriter stream(&file); | |
stream.setAutoFormatting(true); | |
stream.writeStartDocument(); | |
stream.writeStartElement("root"); | |
stream.writeStartElement("item"); | |
stream.writeAttribute("name", "AAA"); | |
stream.writeCharacters ("field1"); | |
stream.writeEndElement(); | |
stream.writeStartElement("item"); | |
stream.writeAttribute("name", "BBB"); | |
stream.writeCharacters ("field2"); | |
stream.writeEndElement(); | |
stream.writeEndDocument();// | |
file.close(); | |
} | |
MainWindow::~MainWindow() | |
{ | |
delete ui; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<root> | |
<item name="AAA">field1</item> | |
<item name="BBB">field2</item> | |
</root> |
0 件のコメント:
コメントを投稿