simplexml_import_dom

(PHP 5, PHP 7)

simplexml_import_domGet a SimpleXMLElement object from a DOM node

说明

simplexml_import_dom ( DOMNode $node [, string $class_name = "SimpleXMLElement" ] ) : SimpleXMLElement

This function takes a node of a DOM document and makes it into a SimpleXML node. This new object can then be used as a native SimpleXML element.

参数

node

A DOM Element node

class_name

You may use this optional parameter so that simplexml_import_dom() will return an object of the specified class. That class should extend the SimpleXMLElement class.

返回值

Returns a SimpleXMLElement 或者在失败时返回 FALSE.

Warning

此函数可能返回布尔值 FALSE,但也可能返回等同于 FALSE 的非布尔值。请阅读 布尔类型章节以获取更多信息。应使用 === 运算符来测试此函数的返回值。

范例

Example #1 Importing DOM

<?php
$dom 
= new DOMDocument;
$dom->loadXML('<books><book><title>blah</title></book></books>');
if (!
$dom) {
    echo 
'Error while parsing the document';
    exit;
}

$s simplexml_import_dom($dom);

echo 
$s->book[0]->title;
?>

以上例程会输出:

blah

参见

相关文章
php com 函数 connect events from a com object to a php objectphp cubrid mysql 兼容性函数 get column information from a result and return as an objectphp dom 函数 gets a domelement object from a simplexmlelement objectphp frontbase 函数 get column information from a result and return as an objectphp firebird/interbase 函数 get an object from a interbase databasephp ldap 函数 parse result object from an ldap extended operationphp ncurses 函数 remove panel from the stack and delete it but not the associated window php oci8 函数 returns the next row from a query as an associative arrayphp oci8 函数 returns the next row from a query as an objectphp simplexml 函数 get a simplexmlelement object from a dom nodephp simplexml 函数 interprets an xml file into an objectphp simplexml 函数 interprets a string of xml into an objectphp sqlite 函数 fetches the next row from a result set as an objectphp stream 函数 return a bucket object from the brigade for operating onphp sdo das relational 函数 returns the special root object in an otherwise empty data graph. used when creating a data graph from scratchphp sdo das xml 函数 creates an xml document object from scratch without the need to load a document from a file or stringphp splpriorityqueue extracts a node from top of the heap and sift upphp swfsound returns a new swfsound object from given filephp tidy returns a tidynode object starting from the body tag of the tidy parse treephp xmlreader returns a copy of the current node as a dom object
关注编程学问公众号