I have the following code, but it doesn't seem to work. First of all, 'fragment' seems to be empty with debugger despite I call createDocumentFragment().
Below part for parsing XML document inside 'data' is to ensure that the source has data. All iterated item has.
Why fragment is empty? Thanks!

Qt Code:
  1. if (mergedXML.documentElement().isNull())
  2. {
  3. QDomElement root = mergedXML.createElement("MergedMeasurements");
  4. mergedXML.appendChild(root);
  5. }
  6.  
  7. foreach (XMLStruct data, mainXMLList)
  8. {
  9. QDomDocumentFragment fragment = data.getXMLDocument()->createDocumentFragment(); // This creates the fragment from QDomDocument.
  10. mergedXML.firstChild().appendChild(fragment);
  11. for (int i=0; i<data.getXMLDocument()->childNodes().count(); i++)
  12. {
  13. if (data.getXMLDocument()->childNodes().at(i).nodeName()=="OMeS")
  14. for (int j=0; j<data.getXMLDocument()->childNodes().at(i).childNodes().count(); j++)
  15. {
  16. if (data.getXMLDocument()->childNodes().at(i).childNodes().at(j).nodeName()=="PMSetup")
  17. {
  18. for (int k=0; k<data.getXMLDocument()->childNodes().at(i).childNodes().at(j).childNodes().count(); k++)
  19. {
  20. if (data.getXMLDocument()->childNodes().at(i).childNodes().at(j).childNodes().at(k).nodeName()=="extraInfoSetup")
  21. {
  22. QDomNode x = data.getXMLDocument()->childNodes().at(i).childNodes().at(j).childNodes().at(k);
  23. log(x.firstChildElement("measurementName").text());
  24. }
  25. }
  26. }
  27. }
  28. }
  29.  
  30. }
To copy to clipboard, switch view to plain text mode