DomNode->attributes

(PHP 4 >= 4.1.0)

DomNode->attributes Returns list of attributes

Description

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.

add a note add a note

User Contributed Notes 2 notes

up
0
Ian Monroe
8 years ago
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();       
    }
}
?>
up
0
steve at realappraiser dot net
9 years ago
$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 ) )
To Top