Table data into XML file format

  • Hi

    can anyone show me how to add table data into XML file format.

  • [quote author="Rajveer" date="1311055350"]can anyone show me how to add table data into XML file format.[/quote]

    You can use class "QDomDocument": which represents an XML document and has methods for adding elements and attributes.

  • Your question is very generic. Can you be a little more specific and maybe give an example of the starting data format and what sort fo format you wish to end up with please?

  • Hi Zap

    QString data from each cell of table.
    Where the columns name will represent the XML tagname.

  • "QXmlStreamWriter": is what you are looking for. No need for a full blown DOM (like QDomDocument) just for data serialization / deserialization (would add processing and memory overhead, would add dependency to QtXml).

    QFile xmlFile("table.xml"); | QIODevice::Truncate);

    QXmlStreamWriter xmlStreamWriter(&file;);

    foreach(RowType row, table.rows)
    foreach(ColumnType column, row.columns)
    xmlStreamWriter.writeTextElement(namespaceUri,, column.value);


    Brain to terminal. Not tested.

Log in to reply