Qt if(!doc.setContent(&file)出错
2017-04-28 10:30
239 查看
QDomDocument doc; if (!doc.setContent(&file)) { file.close(); return ; }执行过程中doc.setContent(&file)一直返回false,首先判断路径没错。
调试:
if(!doc.setContent(&file,true,&errorStr,&errorLine,&errorCol)) { qDebug() << errorStr << "line: " << errorLine << "col: " << errorCol; file.close(); return ; }发现出现错误的地方是1行20列,
instruction = doc.createProcessingInstruction("xml","version=\"1.0\" encoding=\"UTF-8\"");
即encoding前面有个空格,加上就行(教程里面没有空格http://www.qter.org/forum.php?mod=viewthread&tid=189&extra=page%3D1%26filter%3Dauthor%26orderby%3Ddateline%26orderby%3Ddateline)
相关文章推荐
- 用Qt读取xml文件,程序执行到 if(!doc.setContent(&file)) 时候出错
- if (!doc.setContent(&file))出错的解决方法
- QT编译出错解决 libQtCore.so: undefined reference to `QInotifyFileSystemWatcherEngine::create()'
- QT:make: Nothing to be done for `first'和error:QtSql:No such file or directory
- User GhostDoc && Sandcastle Help File Builder Create MSDN-style documentation
- Qt编译出错:“Cannot find file......pro"
- qt 下extern 引用出错 错误:storage class specified for 'childlist'
- Error>: CGContextDrawImage: invalid context 0x0. If you want to see the backtrace, please set CG_CON
- svn出错:Error: File or directory '.' is out of date; try updating(
- Linux 用命令行打开doc pdf等文件以及dpkg: error: parsing file ' /var/lib/dpkg/updates/0012' near line在字段名 #paddi
- 使用exe程序加密解密,web.config时出错 ”Unable to save config to file...."
- Mac 上使用QT 出错:Project ERROR: Xcode not set up properly.
- Servlet输出中文乱码 & response.setContentType()中MIME参数类型总结
- myeclipse工程环境出错:Set project compiler compliance settings to '1.5'
- std::ifstream vShaderfile & vShaderfile.ifstream.exceptions(std::ifstream::badbit)
- 创建SessionFactory出错Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
- Qt4项目迁移Qt5项目一问题解决方法:#include <QtGui/QApplication> ---> No such file or directory
- java.net.ProtocolException: Exceeded stated content-length of: '13824' bytes 用jspSmartUpload.jar下载 出错
- linux下编译QT出错:QMAKESPEC has not been set, so configuration cannot be deduced
- Set fso = Server.CreateObject("Scripting.FileSystemObject")