Results 1 to 12 of 12

Thread: Problem in updating XML file

  1. #1
    Join Date
    Feb 2011
    Posts
    12
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Problem in updating XML file

    Dear Members,

    I've created a sample application to save data in xml. Fist time it is saving data properly. But next time it is corrupting the file. I'm not able to find the problem. Here with I've attached the code. Can any body tell me what is problem in the code.

    N.B. : the xml file will create in C drive with name VCS.xml

    Thank you.
    Attached Files Attached Files

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem in updating XML file

    What do you mean by "it is corrupting the file" ?

    What do you expect? What is the actual result?

  3. #3
    Join Date
    Feb 2011
    Posts
    12
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problem in updating XML file

    Quote Originally Posted by squidge View Post
    What do you mean by "it is corrupting the file" ?

    What do you expect? What is the actual result?
    Thank you very much fro the quick reply.
    First time if i'm entering data like
    name : Alex
    IP : 1.0.0.1
    Group : Friend
    then its creating the file and updating the data.
    If second time if i'm updating data like
    name : Jack
    IP : 1.0.0.1
    Group : Friend
    and I'm opening the file it is not displaying any data.

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem in updating XML file

    So after the first run of your application, the contents of the output file is OK.

    After the second run of your application, the contents of the output file is empty.

    Correct?

  5. #5
    Join Date
    Feb 2011
    Posts
    12
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problem in updating XML file

    Quote Originally Posted by squidge View Post
    So after the first run of your application, the contents of the output file is OK.

    After the second run of your application, the contents of the output file is empty.

    Correct?
    No its filling data. If you ll open the file in note pad u can find there is some data.But if u r opening with internet explorer then its showing error. Here with I've attached the code. If u ll run and fill the data, the file will be creaed on C:\VCS folder.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem in updating XML file

    Is "some data" the data you expect?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Feb 2011
    Posts
    12
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problem in updating XML file

    Quote Originally Posted by wysota View Post
    Is "some data" the data you expect?
    Yes.

    I wanna data like

    Name : john
    Ip : 1.0.0.1
    Group : Company

    Name : Alex
    IP : 1.0.0.2
    Group : Company

    Thank You.

  8. #8
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem in updating XML file

    But the first time internet explorer says the data is ok?

    Sorry, we are still struggling to understand what you mean.

    Maybe you could post the two xml files - first and second.

  9. #9
    Join Date
    Feb 2011
    Posts
    12
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problem in updating XML file

    Quote Originally Posted by squidge View Post
    But the first time internet explorer says the data is ok?

    Sorry, we are still struggling to understand what you mean.

    Maybe you could post the two xml files - first and second.

    Here with I've attached two files. And code already i've uploaded above. If u'll run the code, u can find the file also.
    Thank you.
    Attached Files Attached Files

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem in updating XML file

    After opening the second file it should be obvious for you why the file is wrong. You can't just append another xml document to the first one and expect them to magically merge into one document. You need to update the first document with additional tags that you currently have in the second document. You should also learn how does a well formed xml file should look like.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Feb 2011
    Posts
    12
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problem in updating XML file

    Quote Originally Posted by wysota View Post
    After opening the second file it should be obvious for you why the file is wrong. You can't just append another xml document to the first one and expect them to magically merge into one document. You need to update the first document with additional tags that you currently have in the second document. You should also learn how does a well formed xml file should look like.
    Thank you very much wysota. Can you please tell me how to do this? I'm new to Qt and first time i'm working with XML file. So your small help will help a lot.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem in updating XML file

    Take a look at QDomDocument docs. There is an example of modifying a document and a couple of links to xml specs.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Problem updating a layout
    By Wach in forum Qt Programming
    Replies: 7
    Last Post: 17th August 2010, 00:38
  2. Problem with QListWidget Updating
    By flob in forum Qt Programming
    Replies: 2
    Last Post: 21st November 2009, 17:05
  3. Updating File attributes and it's summary details
    By senthilsp in forum Qt Programming
    Replies: 1
    Last Post: 11th November 2009, 13:31
  4. updating .rc file
    By navi1084 in forum Qt Programming
    Replies: 0
    Last Post: 9th October 2008, 09:53
  5. Problem with QScrollArea updating from 4.0.1 to 4.1.0
    By SkripT in forum Qt Programming
    Replies: 8
    Last Post: 28th January 2006, 22:35

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.