Convert SimpleXML to DOMDocument, not DOMElement

I need to convert a SimpleXML object to a SimpleXML in DOMDocument to use it with DOMXPath . I need DOMXPath so that I can use its registerPHPFunctions method. It can be done?

With dom_import_simplexml I get a DOMElement , not a DOMDocument .

+7
dom xml php simplexml
source share
2 answers

You can extract a document from $ anyDOMNode-> ownerDocument

+11
source share
 $dom=new DOMDocument; $dom->loadXML($sxml->asXML()); 
+1
source share

All Articles