赞
踩
在VS2012中使用QT5.1,加载QtXml来操作xml档。可是出了一个很奇怪的问题。下面是实现代码
- #include "XmlTest.h"
- #include <QtDebug>
-
- void XmlTest::write()
- {
- QDomDocument document;
- QDomElement d=document.createElement("document");
- d.setAttribute("name","DocName");
-
- QDomElement a=document.createElement("author");
- a.setAttribute("name","AuthorName");
-
- QDomText text=document.createTextNode("Some text");
-
- document.appendChild(d);
- d.appendChild(a);
- d.appendChild(text);
-
- QFile file("simple.xml");
- if (!file.open(QIODevice::WriteOnly|QIODevice::Text))
- {
- qDebug("Failed to open file for writing.");
- return;
- }
-
- QTextStream stream(&file);
- stream<<document.toString();
- file.close();
- }

在编译时,出现以下错误
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。