mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
115 lines
5.8 KiB
HTML
115 lines
5.8 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Get a SimpleXMLElement object from a DOM node</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.simplexml-import-dom" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">simplexml_import_dom</h1>
|
|
<p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">simplexml_import_dom</span> — <span class="dc-title">Get a <em>SimpleXMLElement</em> object from a DOM node</span></p>
|
|
|
|
</div>
|
|
<div class="refsect1 description" id="refsect1-function.simplexml-import-dom-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>simplexml_import_dom</strong></span>
|
|
( <span class="methodparam"><span class="type"><a href="class.domnode.html" class="type DOMNode">DOMNode</a></span> <code class="parameter">$node</code></span>
|
|
[, <span class="methodparam"><span class="type">string</span> <code class="parameter">$class_name</code><span class="initializer"> = "SimpleXMLElement"</span></span>
|
|
] ) : <span class="type"><a href="class.simplexmlelement.html" class="type SimpleXMLElement">SimpleXMLElement</a></span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
This function takes a node of a <a href="book.dom.html" class="link">DOM</a>
|
|
document and makes it into a SimpleXML node. This new object can
|
|
then be used as a native SimpleXML element.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.simplexml-import-dom-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">node</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
A <a href="book.dom.html" class="link">DOM</a> Element node
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">class_name</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
You may use this optional parameter so that
|
|
<span class="function"><strong>simplexml_import_dom()</strong></span> will return an object of
|
|
the specified class. That class should extend the
|
|
<span class="type"><a href="class.simplexmlelement.html" class="type SimpleXMLElement">SimpleXMLElement</a></span> class.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.simplexml-import-dom-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns a <span class="type"><a href="class.simplexmlelement.html" class="type SimpleXMLElement">SimpleXMLElement</a></span> 或者在失败时返回 <strong><code>FALSE</code></strong>.
|
|
</p>
|
|
<div class="warning"><strong class="warning">Warning</strong><p class="simpara">此函数可能返回布尔值
|
|
<strong><code>FALSE</code></strong>,但也可能返回等同于 <strong><code>FALSE</code></strong> 的非布尔值。请阅读 <a href="language.types.boolean.html" class="link">布尔类型</a>章节以获取更多信息。应使用
|
|
<a href="language.operators.comparison.html" class="link">===
|
|
运算符</a>来测试此函数的返回值。</p></div>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.simplexml-import-dom-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-6592">
|
|
<p><strong>Example #1 Importing DOM</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br />$dom </span><span style="color: #007700">= new </span><span style="color: #0000BB">DOMDocument</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$dom</span><span style="color: #007700">-></span><span style="color: #0000BB">loadXML</span><span style="color: #007700">(</span><span style="color: #DD0000">'<books><book><title>blah</title></book></books>'</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$dom</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">'Error while parsing the document'</span><span style="color: #007700">;<br /> exit;<br />}<br /><br /></span><span style="color: #0000BB">$s </span><span style="color: #007700">= </span><span style="color: #0000BB">simplexml_import_dom</span><span style="color: #007700">(</span><span style="color: #0000BB">$dom</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$s</span><span style="color: #007700">-></span><span style="color: #0000BB">book</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">]-></span><span style="color: #0000BB">title</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
<div class="example-contents"><p>以上例程会输出:</p></div>
|
|
<div class="example-contents screen">
|
|
<div class="cdata"><pre>
|
|
blah
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.simplexml-import-dom-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="dom_import_simplexml.html" class="function" rel="rdfs-seeAlso">dom_import_simplexml()</a> - Gets a DOMElement object from a
|
|
SimpleXMLElement object</span></li>
|
|
<li class="member"><a href="simplexml.examples_basic.html" class="xref">Basic SimpleXML usage</a></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |