note 46119 deleted from function.dom-domelement-getelementsbytagname by didou

From: Date: Mon, 17 Apr 2006 12:54:19 +0000
Subject: note 46119 deleted from function.dom-domelement-getelementsbytagname by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-108328@lists.php.net to get a copy of this message
Note Submitter: gem at rellim dot com ---- Here is an example of how to use 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->documentElement->firstChild->getElementsByTagName('param'); foreach ($params as $param) { echo $param -> getAttribute('name').'<br>'; } ?> Expected result: ---------------- param1 param2

« previous php.notes (#108328) next »