(PHP 5, PHP 7, PHP 8)
DOMNamedNodeMap::getNamedItem — Retourne un nœud spécifié par son nom
Récupère un nœud spécifié par son nodeName
.
qualifiedName
Le nodeName
du nœud à récupérer.
Un nœud (de n'importe quel type) avec un nodeName
spécifié, ou
null
si aucun nœud n'est trouvé.
Exemple #1 Récupérer un attribut sur un nœud
<?php
$doc = new DOMDocument;
$doc->load('book.xml');
$id = $doc->firstChild->attributes->getNamedItem('id');
?>
Exemple #2 Accéder un élément avec la syntaxe de tableau
<?php
$id = $doc->firstChild->attributes['id'];
?>