PHP: DOMDocument->getElementsByTagName() - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

DOMDocument->getElementsByTagNameNS() DOMDocument->getElementById()

Last updated: Fri, 26 Jan 2007

view this page in

# 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 User Contributed Notes
DOMDocument->getElementsByTagName()
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`
add a note
DOMDocument->getElementsByTagNameNS() DOMDocument->getElementById()

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 09:32:46 2007 PST