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
Forum Updated to NodeBB v4.3 + New Features

Insert data after the corresponding node in XML

Scheduled Pinned Locked Moved Unsolved General and Desktop
xml
2 Posts 2 Posters 789 Views 2 Watching
  • 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.
  • Pradeep KumarP Offline
    Pradeep KumarP Offline
    Pradeep Kumar
    wrote on last edited by A Former User
    #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

    matthew.kuiashM 1 Reply Last reply
    0
    • Pradeep KumarP Pradeep Kumar

      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

      matthew.kuiashM Offline
      matthew.kuiashM Offline
      matthew.kuiash
      wrote on 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

      • Login

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