PHP attributes() Function

This function provides the attributes and values defined within an xml tag.

public SimpleXMLElement SimpleXMLElement::attributes ([ string $ns = NULL [, bool $is_prefix = FALSE ]] )

Example -

ParameterDescription
nsAn optional namespace for the retrieved attributes
is_prefixDefault to FALSE

Returns a SimpleXMLElement object that can be iterated over to loop through the attributes on the tag.Returns NULL if called on a SimpleXMLElement object that already represents an attribute and not a tag.