Insert data after the corresponding node in XML



  • 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 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.