I have a xml template like given below.
Qt Code:
  1. <Main_tag>
  2. <SubTag1>
  3. <Content_tag1> ... </Content_tag1>
  4. <Content_tag1> ... </Content_tag1>
  5. <Content_tag1> ... </Content_tag1>
  6. <Content_tag1> ... </Content_tag1>
  7. </SubTag1>
  8. <SubTag2>
  9.  
  10. </SubTag2>
  11. <SubTag3>
  12.  
  13. <SubTag3>
  14. <SubTag4>
  15. <Content_tag4> ... </Content_tag4>
  16. <Content_tag4> ... </Content_tag4>
  17. <Content_tag4> ... </Content_tag4>
  18. <Content_tag4> ... </Content_tag4>
  19. </Subtag4>
  20. </Main_tag>
To copy to clipboard, switch view to plain text mode 
The program should make a copy(template will be read-only) and edit it according to the previous part of program. but basically a final copy should look somthing like.
Qt Code:
  1. <Main_tag>
  2. <SubTag1>
  3. <Content_tag1> ... </Content_tag1>
  4. <Content_tag1> ... </Content_tag1>
  5. <Content_tag1> ... </Content_tag1>
  6. <Content_tag1> ... </Content_tag1>
  7. </SubTag1>
  8. <SubTag2>
  9. <Content_tag2> ... </Content_tag2>
  10. <Content_tag2> ... </Content_tag2>
  11. </SubTag2>
  12. <SubTag3>
  13. <Content_tag3> ... </Content_tag3>
  14. <Content_tag3> ... </Content_tag3>
  15. <Content_tag3> ... </Content_tag3>
  16. </SubTag3>
  17. <SubTag4>
  18. <Content_tag4> ... </Content_tag4>
  19. <Content_tag4> ... </Content_tag4>
  20. <Content_tag4> ... </Content_tag4>
  21. <Content_tag4> ... </Content_tag4>
  22. </Subtag4>
  23. </Main_tag>
To copy to clipboard, switch view to plain text mode 
the tags and remains exactly the same, and the number of childs in and can vary according to previous part of the program. I am open to either DomDocument or XmlStreamReader. it should also make a attribute tab for every attribute like Content_tag2 or Content_tag3

I have a basic domdocument code, where the program opens the xml file and reads, but i am stuck at the part where the program should make a copy and add in attributes in correct header.
Qt Code:
  1. void XMLReader::ReadFromXMLFile()
  2. {
  3. QString filename="mypath";
  4. File =new QFile(filename);
  5.  
  6. File->open(QIODevice::ReadOnly);
  7.  
  8. if (!File->open(QFile::ReadOnly | QFile::Text))
  9. {
  10. qDebug("Error: Cannot read file ");
  11. }
  12. dom.setContent(File);
  13. QDomElement FirstElement = dom.documentElement();
  14. QDomNode Node = FirstElement.firstChild();
  15. while (!Node.isNull())
  16. {
  17. QDomElement Element = Node.toElement();
  18. if(!Element.isNull())
  19. {
To copy to clipboard, switch view to plain text mode 

Any help will be appriciated.