PHP Doku:: Returns list of attributes - function.domnode-attributes.html

Verlauf / Chronik / History: (2) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzXML-ManipulationDOM-XMLDOM-XML-FunktionenDomNode->attributes

Ein Service von Reinhard Neidl - Webprogrammierung.

DOM-XML-Funktionen

<<DomNode->append_sibling

DomNode->child_nodes>>

DomNode->attributes

(PHP 4 >= 4.1.0)

DomNode->attributes Returns list of attributes

Beschreibung

array DomNode->attributes ( void )

This function only returns an array of attributes if the node is of type XML_ELEMENT_NODE.

(PHP >= 4.3 only) If no attributes are found, NULL is returned.


2 BenutzerBeiträge:
- Beiträge aktualisieren...
Ian Monroe
29.11.2005 17:03
A function to get the value of an attribute given the name of the desired attribute and the results of attributes() to the second parameter.
<?php
function getAttribute($name, $att)
{
    foreach(
$att as $i)
    {
        if(
$i->name()==$name)
            return
$i->value();       
    }
}
?>
steve at realappraiser dot net
5.01.2005 21:41
$xpath = $parseDoc->xpath_new_context($parseDoc);      
$getResultSearch = $xpath->xpath_eval("//PROPERTY_INFORMATION_RESPONSE/_PRODUCT");
$nodesetResult = $getResultSearch->nodeset;
$var1=$getResultSearch->nodeset[0]->attributes() ;
implode($var1);
print_r ($var1 )  ;

// it prints something like this:::::

Array ( [0] => domattribute Object ( [type] => 2 [name] => _PrettyAttr [value] => Y [0] => 26 [1] => 161068800 ) )



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)