QDomDocument doc; QDomElement root = doc.createElement("root"); doc.appendChild(root); QDomElement child = doc.createElement("child"); root.appendChild(child); QDomDocument* owner = child.ownerDocument(); // returns pointer to 'doc'
void processElement(QDomElement element) { QDomDocument* doc = element.ownerDocument(); // do something with 'doc' } QDomDocument doc; QDomElement root = doc.createElement("root"); doc.appendChild(root); QDomElement child = doc.createElement("child"); root.appendChild(child); processElement(child);In this example, a function is defined that takes a QDomElement as a parameter. The ownerDocument method is called on the element and returns a pointer to the QDomDocument that owns the element. This pointer is then used in the function to do something with the document. Package/library: Qt's XML module.