QDomNode.setContent() doesn't work...
-
Hello
I'm trying the following:@QDomDocument configDoc; QFile storage("c:/Time/data.xml"); if(!storage.open(QIODevice::ReadOnly)) { qDebug("ERROR opening file"); } if( !configDoc.setContent( &storage ) ) { qDebug("ERROR settings content"); } storage.close();@
Where the file contains e.g.:
@<?xml version="1.0"?>
<config version="0.1">
<id>123</id>
<hwVersion>2</hwVersion>
</config>@But it always fails to set the content (setContent() -> false) I've include
#include <QFile>
#include <QtXml>and added xml to the pro file but nothing seems to work. Could this be platform related? I have
the same code in use on a linux platform based solution and there it works fine, but can't manage to get
it to work on windows.. (just to clarify, it's not the same code, so there might be defferences I ahven't noticed,
but this function is copy/pasted)Br.
Richard -
You could try appending QIODevice::Text to your open mode flags; you might be running into line ending issues on Windows.
Another option would be passing the optional parameters to setContent() required for reading the parse error and taking a look at it.