Is there a way I can get the document root from a child Element or Node? I am migrating from a library that works with any of Document, Element or Node to one that works only with Document. eg.
From:
element.xpath('/a/b/c') # 4Suite
to:
xpath.find('/a/b/c', doc) # pydomxpath
Nodeobjects have anownerDocumentproperty that refers to theDocumentobject associated with the node. See http://www.w3.org/TR/DOM-Level-2-Core/core.html#node-ownerDoc.This property is not mentioned in the Python documentation, but it’s available. Example:
Output: