Aye. Is this the kind of dirt you were thinking of?
Qt Code:
  1. QString MainWindow::makeTextFromElement(QDomElement e) {
  2. QString tag = e.tagName();
  3. bool addTag = !e.tagName().isEmpty();
  4. QString output = "";
  5. if (addTag) output = "<" + e.tagName();
  6. QDomNamedNodeMap atts = e.attributes();
  7. int len = atts.length();
  8. for (int i = 0; i < len; i++) {
  9. QString name = atts.item(i).toAttr().name();
  10. QString value = atts.item(i).toAttr().value();
  11. output += " " + name + "=\"" + value + "\"";
  12. }
  13. if (addTag) output += ">";
  14. QDomNodeList children = e.childNodes();
  15. len = children.length();
  16. for (int i = 0; i < len; i++) {
  17. output += makeTextFromElement(children.item(i).toElement());
  18. }
  19. output += e.text();
  20. if (addTag) output += "</" + e.tagName() + ">";
  21. return output;
  22. }
To copy to clipboard, switch view to plain text mode 
(It's working)