标签: php xml dom simplexml
我需要将SimpleXML对象转换为DOMDocument,并将其与DOMXPath一起使用。我需要DOMXPath以便我可以使用它的registerPHPFunctions方法。可以这样做吗?
SimpleXML
DOMDocument
DOMXPath
registerPHPFunctions
使用dom_import_simplexml我得到DOMElement,而不是DOMDocument。
dom_import_simplexml
DOMElement
答案 0 :(得分:11)
您可以从$anyDOMNode->ownerDocument
答案 1 :(得分:1)
$dom=new DOMDocument; $dom->loadXML($sxml->asXML());