Wow... that was a stupid mistake. It essentially is like a link in a link list. Once you append the element into the list of XML tags, that element becomes the new link in the chain, as the previous element was replaced by the new element. Therefore, the links to the previous and next sibling elements are null pointers. Therefore, by doing the following, I got it to work with your recommendation. (oh, I did have it returning e2 = n.replaceChild(elem, e2), but that was incorrect, as it needs to be the next sibling element. I just didn't have it reflected in the code I posted above, as it was just a way to quickly convey what I was trying to express).

Qt Code:
  1. QDomNode n = root.firstChild();
  2. while(!n.isNull())
  3. {
  4. QDomElement e = n.toElement();
  5. if(!e.isNull())
  6. {
  7. if((e.tagName() == "config") and (e.attribute("name", "") == "Eddie"))
  8. {
  9. QDomElement e2 = n.firstChildElement();
  10. while(!e2.isNull())
  11. {
  12. if(e2.tagName() == "execdir")
  13. {
  14. QDomElement elem = doc.createElement("execdir");
  15. elem.appendChild(doc.createTextNode("EXECUTABLE DIRECTORY"));
  16. e2 = n.replaceChild(elem, e2).nextSiblingElement();
  17. }
  18. else if(e2.tagName() == "binary")
  19. {
  20. QDomElement elem = doc.createElement("binary");
  21. elem.appendChild(doc.createTextNode("EXECUTABLE"));
  22. e2 = n.replaceChild(elem, e2).nextSiblingElement();
  23. }
  24. else e2 = e2.nextSiblingElement();
  25. }
  26. }
  27. }
  28.  
  29. n = n.nextSibling();
  30. }
To copy to clipboard, switch view to plain text mode 


That now works, as stated. Just thought I would post the final code for anyone else looking at the same dumb mistake I was making.