I need to convert a SimpleXML
object to a DOMDocument
, to use it with DOMXPath
. I need DOMXPath so that I can use its registerPHPFunctions
method. Can this be done?
我需要将SimpleXML对象转换为DOMDocument,以便与DOMXPath一起使用。我需要DOMXPath,这样我就可以使用它的registerPHPFunctions方法。这个可以做吗?
With dom_import_simplexml
I get a DOMElement
, not DOMDocument
.
使用dom_import_simplexml,我得到的是DOMElement,而不是DOMDocument。
2 个解决方案
#2
1
$dom=new DOMDocument;
$dom->loadXML($sxml->asXML());
#1
#2
1
$dom=new DOMDocument;
$dom->loadXML($sxml->asXML());