Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Insert data after the corresponding node in XML

Insert data after the corresponding node in XML

Scheduled Pinned Locked Moved Unsolved General and Desktop
xml
2 Posts 2 Posters 770 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pradeep Kumar
    wrote on 9 Feb 2017, 17:39 last edited by A Former User 2 Sept 2017, 20:11
    #1

    Hi,

    i am using `` QDomDocument```, to read and write the data into XML.

    <first>
       <second>
                 <info>Hello</info>
                 <company>Qt</company>
        </second> 
    </first>        
    

    i am creating the elements , using QDomElement .
    And using

            QTextStream stream(&file);
            stream << domDocument.toString();
    

    i am inserting the values, problem is it is inserting from the first nodes, but i want to insert after

    <first>
     ...
    
    </first>
    

    i want to insert in this manner, how can it be achieved.?..

    <first>
       <second>
                 <info>Hello</info>
                 <company>Qt</company>
        </second> 
       <second>
                 <info>Hello</info>
                 <company>Qt</company>
        </second> 
    </first>     
    

    Now it is currently inserting like this :

    <first>
       <second>
                 <info>Hello</info>
                 <company>Qt</company>
        </second> 
    </first>        
    <first>
       <second>
                 <info>Hello</info>
                 <company>Qt</company>
        </second> 
    </first>        
    

    only from second node?.

    Thanks,

    Edit: Added code tags -- @Wieland

    Pradeep Kumar
    Qt,QML Developer

    M 1 Reply Last reply 9 Feb 2017, 20:03
    0
    • P Pradeep Kumar
      9 Feb 2017, 17:39

      Hi,

      i am using `` QDomDocument```, to read and write the data into XML.

      <first>
         <second>
                   <info>Hello</info>
                   <company>Qt</company>
          </second> 
      </first>        
      

      i am creating the elements , using QDomElement .
      And using

              QTextStream stream(&file);
              stream << domDocument.toString();
      

      i am inserting the values, problem is it is inserting from the first nodes, but i want to insert after

      <first>
       ...
      
      </first>
      

      i want to insert in this manner, how can it be achieved.?..

      <first>
         <second>
                   <info>Hello</info>
                   <company>Qt</company>
          </second> 
         <second>
                   <info>Hello</info>
                   <company>Qt</company>
          </second> 
      </first>     
      

      Now it is currently inserting like this :

      <first>
         <second>
                   <info>Hello</info>
                   <company>Qt</company>
          </second> 
      </first>        
      <first>
         <second>
                   <info>Hello</info>
                   <company>Qt</company>
          </second> 
      </first>        
      

      only from second node?.

      Thanks,

      Edit: Added code tags -- @Wieland

      M Offline
      M Offline
      matthew.kuiash
      wrote on 9 Feb 2017, 20:03 last edited by
      #2

      @Pradeep-Kumar Do you have your code please? Sounds like you're adding nodes at the root level. You need to insert a sibling after the first/second node.

      The legendary cellist Pablo Casals was asked why he continued to practice at age 90. "Because I think I'm making progress," he replied.

      1 Reply Last reply
      2

      2/2

      9 Feb 2017, 20:03

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved