Results 1 to 7 of 7

Thread: Format XML file

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2012
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    5

    Default Re: Format XML file

    Quote Originally Posted by Santosh Reddy View Post
    Qt Code:
    1. void format(void)
    2. {
    3. QDomDocument input;
    4.  
    5. QFile inFile("D:/input.xml");
    6. QFile outFile("D:/output.xml");
    7.  
    8. inFile.open(inFile.Text | inFile.ReadOnly);
    9. outFile.open(outFile.Text | outFile.WriteOnly);
    10.  
    11. input.setContent(&inFile);
    12.  
    13. QDomDocument output(input);
    14. QTextStream stream(&outFile);
    15. output.save(stream, 2);
    16. }
    To copy to clipboard, switch view to plain text mode 
    What i have to do if i have to save the contents inside the same file . like in the above case for D:/input.xml .

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Format XML file

    Write the output to a temporary file and, when that is successfully closed rename it to replace the original.
    Or, write the result to a buffer in memory and when that is complete write the buffer to the file.

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

    vikuseth (21st December 2012)

Similar Threads

  1. Replies: 5
    Last Post: 1st June 2011, 09:28
  2. Replies: 0
    Last Post: 21st July 2010, 11:32
  3. read the file which has the format of odp!
    By sunnysun520 in forum Qt Programming
    Replies: 11
    Last Post: 14th May 2009, 16:14
  4. QImage, get file format
    By greenvirag in forum Qt Programming
    Replies: 6
    Last Post: 29th December 2008, 14:13
  5. QSettings, my own format of config-file
    By IPFreely in forum Qt Programming
    Replies: 2
    Last Post: 14th November 2007, 21:07

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.