I'm translating my C# code for YouTube video comments into PHP. In order to properly nest comment replies I need to re-arrange XML nodes. In PHP I'm using DOMDocument and DOMXPath which closely corresponds to C# XmlDocument. I've gotten pretty far in my translation but now I'm stuck on getting the parent node of a DOMElement. A DOMElement does not have a parent_node() property, only a DOMNode provides that property.
After determining that a comment is a reply to a previous comment based in the string "in-reply-to" in a link element, I need to get its parent node in order to nest it beneath the comment it is in reply to:
// Get the parent entry node of this link element
$importnode = $objReplyXML->importNode($link->parent_node(), true);