Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

DOMDocument->getElementsByTagName()

(no version information, might be only in CVS)

DOMDocument->getElementsByTagName() -- Searches for all elements with given tag name

Описание

class DOMDocument {

DOMNodeList getElementsByTagName ( string name )

}

This function returns a new instance of class DOMNodeList containing the elements with a given tag name.

Список параметров

name

The name of the tag to match on. The special value * matches all tags.

Возвращаемые значения

A new DOMNodeList object containing all the matched elements.

Смотрите также

DOMDocument->getElementsByTagNameNS()



add a note add a note User Contributed Notes
DOMDocument->getElementsByTagName()
Francois Hill
30-Jul-2007 07:36
Careful : getElementsByTagName will yield all elements with the given tag name under the present node, at any sub-level (i.e. among child nodes and all other descendant nodes)
Finding values of a node
14-Mar-2007 03:01
I don't know if this is that obvious but it was not for me, so in addition to gem at rellim dot com's posting:
adding

<?php
echo $param -> nodeValue.'<br>';
?>

to the loop will output
value1
value2
value3
gem at rellim dot com
29-Sep-2004 04:20
Here is an example of getElementsByTagName():

<?php
$xml
=<<<EOT
<?xml version="1.0"?>
<config>
  <section id="section1">
   <param name="param1">value1</param>
   <param name="param2">value2</param>
  </section>
  <section id="section2">
   <param name="param3">value3</param>
  </section>
</config>
EOT;

$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->loadXML($xml);
$params = $dom->getElementsByTagName('param');

foreach (
$params as $param) {
       echo
$param -> getAttribute('name').'<br>';
}
?>

Expected result:
--------------
param1
param2
param3

 
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571