note 108809 deleted from domelement.getattributenode by danbrown
| From: | danbrown@php.net | Date: | Fri, 25 May 2012 23:59:33 +0000 |
| Subject: | note 108809 deleted from domelement.getattributenode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-188246@lists.php.net to get a copy of this message | ||
Note Submitter: Colepicolo
----
XML Document:
<mods>
<...>
<namePart type="family">Abikoff</namePart>
<namePart type="given">Howard B.</namePart>
<...>
</mods>
---
PHP file:
$doc = new DOMDocument(); // initialize the class
$doc->load( 'example.xml' ); // load the xml document
foreach($mods as $mod) { // main tag
$namesPart = $doc->getElementsByTagName( "namePart" );
foreach( $namesPart as $namePart )
{
$namePart = $mod->getElementsByTagName( "namePart" );
$attr = $namePart->item(0)->getAttributeNode("type");
echo $output = $namePart->item(0)->nodeValue . "<br>";
}
}