mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Clarified that this method matches on the local tag name and added basic usage example
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@322539 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
3268a9eed3
commit
ed1765af82
1 changed files with 45 additions and 5 deletions
|
@ -3,7 +3,7 @@
|
|||
<refentry xml:id="domdocument.getelementsbytagname" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument::getElementsByTagName</refname>
|
||||
<refpurpose>Searches for all elements with given tag name</refpurpose>
|
||||
<refpurpose>Searches for all elements with given local tag name</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
|
@ -13,8 +13,8 @@
|
|||
</methodsynopsis>
|
||||
<para>
|
||||
This function returns a new instance of class
|
||||
<classname>DOMNodeList</classname> containing the elements with a given
|
||||
tag name.
|
||||
<classname>DOMNodeList</classname> containing all the elements with a given
|
||||
local tag name.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="parameters">
|
||||
|
@ -25,8 +25,8 @@
|
|||
<term><parameter>name</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The name of the tag to match on. The special value <literal>*</literal>
|
||||
matches all tags.
|
||||
The local name (without namespace) of the tag to match on. The special value <literal>*</literal>
|
||||
matches all tags.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
@ -40,6 +40,46 @@
|
|||
elements.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="examples"><!-- {{{ -->
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example xml:id="domdocument.getelementsbytagname.example.basic"><!-- {{{ -->
|
||||
<title>Basic Usage Example</title>
|
||||
<para>
|
||||
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$xml = <<< XML
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<books>
|
||||
<book>Patterns of Enterprise Application Architecture</book>
|
||||
<book>Design Patterns: Elements of Reusable Software Design</book>
|
||||
<book>Clean Code</book>
|
||||
</books>
|
||||
XML;
|
||||
|
||||
$dom = new DOMDocument;
|
||||
$dom->loadXml($xml);
|
||||
$books = $dom->getElementsByTagName('book');
|
||||
foreach ($books as $book) {
|
||||
echo $book->nodeValue, PHP_EOL;
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Patterns of Enterprise Application Architecture
|
||||
Design Patterns: Elements of Reusable Software Design
|
||||
Clean Code
|
||||
]]>
|
||||
</screen>
|
||||
</example><!-- }}} -->
|
||||
</para>
|
||||
</refsect1><!-- }}} -->
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
|
|
Loading…
Reference in a new issue