Dom\import_simplexml
(PHP 8 >= 8.4.0)
Dom\import_simplexml — Gets a Dom\Attr or Dom\Element object from a SimpleXMLElement object
说明
This function takes the given attribute or element node
(a
SimpleXMLElement instance) and creates a
Dom\Attr or Dom\Element node, respectively.
The new Dom\Node refers to the same underlying XML node
as the SimpleXMLElement.
返回值
The Dom\Attr or Dom\Element.
示例
示例 #1 Import SimpleXML into DOM and modify SimpleXML through DOM
Error handling omitted for brevity.
<?php
$sxe = simplexml_load_string('<books><book><title>blah</title></book></books>');
$elt = Dom\import_simplexml($sxe);
$elt->setAttribute("foo", "bar");
echo $sxe->asXML();
?>
以上示例会输出:
<?xml version="1.0"?> <books foo="bar"><book><title>blah</title></book></books>
参见
- simplexml_import_dom() - Get a SimpleXMLElement object from an XML or HTML node
+添加备注
用户贡献的备注
此页面尚无用户贡献的备注。
备份地址:http://www.lvesu.com/blog/php/function.dom-ns-import-simplexml.php