Results 1 to 10 of 10

Thread: Writing an XML file

  1. #1
    Join Date
    Mar 2006
    Posts
    26
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Writing an XML file

    What's the best way to write an XML file?

    I tried using QFile and QTextStream...but any time I wanted to add something to the file...it would delete the current data. Is there a way to write to a file and not delete the contents?

    I know about QDomDocument....but I'm having some difficultity trying to understand exactly how the formatting goes then getting to a file.

    Thanks!

    Rob

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Writing an XML file

    In what mode do you open that file?

  3. The following user says thank you to jacek for this useful post:

    qball2k5 (17th March 2006)

  4. #3
    Join Date
    Mar 2006
    Posts
    26
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Writing an XML file

    I ReadWrite

  5. #4
    Join Date
    Mar 2006
    Posts
    26
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Writing an XML file

    I used ReadWrite? Is that wrong? Should I just use Write? Will that append?

  6. #5
    Join Date
    Mar 2006
    Posts
    26
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Writing an XML file

    Got it...use Append instead of ReadWrite...thanks!

  7. #6
    Join Date
    Jan 2006
    Location
    Minsk, Brest, Belarus
    Posts
    54
    Thanks
    3
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Writing an XML file

    Use QDom or SAX for writing XML files. It is the best way to do it...

  8. #7
    Join Date
    Feb 2006
    Location
    Roma ( Italy )
    Posts
    7
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Writing an XML file


  9. #8
    Join Date
    Jan 2006
    Posts
    109
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Writing an XML file

    Quote Originally Posted by Xagen
    Use QDom or SAX for writing XML files. It is the best way to do it...
    SAX (and to a lesser extent DOM) is more approriate for parsing files, not writing them, QDomDocument::toString does help to write a file.

  10. #9
    Join Date
    Jan 2006
    Location
    Minsk, Brest, Belarus
    Posts
    54
    Thanks
    3
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Writing an XML file

    Quote Originally Posted by dimitri
    SAX (and to a lesser extent DOM) is more approriate for parsing files, not writing them, QDomDocument::toString does help to write a file.
    Look at the Sax and Dom's examples in the QT distribution...

  11. #10
    Join Date
    Mar 2006
    Posts
    10
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Re: Writing an XML file

    Read the following book:
    "Programming with QT3" by J.Blanchette.

Similar Threads

  1. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  2. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  3. Writing a XML file
    By Djony in forum Qt Programming
    Replies: 7
    Last Post: 5th February 2007, 16:23
  4. Writing to file at specific
    By safknw in forum Qt Programming
    Replies: 3
    Last Post: 1st December 2006, 11:12
  5. XML file writing
    By mbjerkne in forum Qt Programming
    Replies: 2
    Last Post: 24th May 2006, 19:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.