[英]Convert SimpleXML to DOMDocument, not DOMElement
I need to convert a SimpleXML
object to a DOMDocument
, to use it with DOMXPath
. 我需要将
SimpleXML
对象转换为DOMDocument
,以便与DOMXPath
一起使用。 I need DOMXPath so that I can use its registerPHPFunctions
method. 我需要DOMXPath,以便我可以使用其
registerPHPFunctions
方法。 Can this be done? 可以这样做吗?
With dom_import_simplexml
I get a DOMElement
, not DOMDocument
. 使用
dom_import_simplexml
我得到一个DOMElement
,而不是DOMDocument
。
您可以从$ anyDOMNode-> ownerDocument中获取文档
$dom=new DOMDocument;
$dom->loadXML($sxml->asXML());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.