Important: Please read the Qt Code of Conduct -

QDomNode.setContent() doesn't work...

  • Hello
    I'm trying the following:

    @QDomDocument configDoc;
    QFile storage("c:/Time/data.xml");
        qDebug("ERROR opening file");
    if( !configDoc.setContent( &storage ) )
        qDebug("ERROR settings content");

    Where the file contains e.g.:

    @<?xml version="1.0"?>
    <config version="0.1">

    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)


  • 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.

Log in to reply