<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.domdocument.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'domdocument.getelementsbytagnamens.php',
    1 => 'DOMDocument::getElementsByTagNameNS',
    2 => 'Searches for all elements with given tag name in specified namespace',
  ),
  'up' => 
  array (
    0 => 'class.domdocument.php',
    1 => 'DOMDocument',
  ),
  'prev' => 
  array (
    0 => 'domdocument.getelementsbytagname.php',
    1 => 'DOMDocument::getElementsByTagName',
  ),
  'next' => 
  array (
    0 => 'domdocument.importnode.php',
    1 => 'DOMDocument::importNode',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/dom/domdocument/getelementsbytagnamens.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="domdocument.getelementsbytagnamens" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DOMDocument::getElementsByTagNameNS</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">DOMDocument::getElementsByTagNameNS</span> &mdash; <span class="dc-title">
   Searches for all elements with given tag name in specified namespace
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-domdocument.getelementsbytagnamens-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>DOMDocument::getElementsByTagNameNS</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$namespace</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$localName</code></span>): <span class="type"><a href="class.domnodelist.php" class="type DOMNodeList">DOMNodeList</a></span></div>

  <p class="para rdfs-comment">
   Returns a <span class="classname"><a href="class.domnodelist.php" class="classname">DOMNodeList</a></span> of all elements with a given 
   local name and a namespace URI.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-domdocument.getelementsbytagnamens-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">namespace</code></dt>
     <dd>
      <p class="para">
       The namespace URI of the elements to match on.
       The special value <code class="literal">&quot;*&quot;</code> matches all namespaces.
       Passing <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> matches the empty namespace.
      </p>
     </dd>
    
    
     <dt><code class="parameter">localName</code></dt>
     <dd>
      <p class="para">
       The local name of the elements to match on.
       The special value <code class="literal">&quot;*&quot;</code> matches all local names.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-domdocument.getelementsbytagnamens-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   A new <span class="classname"><a href="class.domnodelist.php" class="classname">DOMNodeList</a></span> object containing all the matched 
   elements.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-domdocument.getelementsbytagnamens-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.3</td>
      <td>
       <code class="parameter">namespace</code> is nullable now.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-domdocument.getelementsbytagnamens-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 Get all the XInclude elements</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$xml </span><span style="color: #007700">= &lt;&lt;&lt;EOD<br /></span><span style="color: #DD0000">&lt;?xml version="1.0" ?&gt;<br />&lt;chapter xmlns:xi="http://www.w3.org/2001/XInclude"&gt;<br />&lt;title&gt;Books of the other guy..&lt;/title&gt;<br />&lt;para&gt;<br /> &lt;xi:include href="book.xml"&gt;<br />  &lt;xi:fallback&gt;<br />   &lt;error&gt;xinclude: book.xml not found&lt;/error&gt;<br />  &lt;/xi:fallback&gt;<br /> &lt;/xi:include&gt;<br /> &lt;include&gt;<br />  This is another namespace<br /> &lt;/include&gt;<br />&lt;/para&gt;<br />&lt;/chapter&gt;<br /></span><span style="color: #007700">EOD;<br /></span><span style="color: #0000BB">$dom </span><span style="color: #007700">= new </span><span style="color: #0000BB">DOMDocument</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// load the XML string defined above<br /></span><span style="color: #0000BB">$dom</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">loadXML</span><span style="color: #007700">(</span><span style="color: #0000BB">$xml</span><span style="color: #007700">);<br /><br />foreach (</span><span style="color: #0000BB">$dom</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getElementsByTagNameNS</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://www.w3.org/2001/XInclude'</span><span style="color: #007700">, </span><span style="color: #DD0000">'*'</span><span style="color: #007700">) as </span><span style="color: #0000BB">$element</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">'local name: '</span><span style="color: #007700">, </span><span style="color: #0000BB">$element</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">localName</span><span style="color: #007700">, </span><span style="color: #DD0000">', prefix: '</span><span style="color: #007700">, </span><span style="color: #0000BB">$element</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prefix</span><span style="color: #007700">, </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例会输出：</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">local name: include, prefix: xi
local name: fallback, prefix: xi</pre>
</div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-domdocument.getelementsbytagnamens-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="domdocument.getelementsbytagname.php" class="methodname" rel="rdfs-seeAlso">DOMDocument::getElementsByTagName()</a> - Searches for all elements with given local tag name</span></li>
   </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>