downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  

<SimpleXMLElement->asXML()SimpleXMLElement->children()>
Last updated: Thu, 26 Jun 2008

SimpleXMLElement->attributes()

(PHP 5 >= 5.0.1)

SimpleXMLElement->attributes() — Identifies an element's attributes

Description

SimpleXMLElement
SimpleXMLElement attributes ([ string $ns [, bool $is_prefix ]] )

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

Note: SimpleXML has made a rule of adding iterative properties to most methods. They cannot be viewed using var_dump() or anything else which can examine objects.

Parameters

ns

An optional namespace for the retrieved attributes

is_prefix

Default to FALSE

Return Values

Examples

Example #1 Interpret an XML string

<?php
$string
= <<<XML
<a xmlns:b>
 <foo name="one" game="lonely">1</foo>
</a>
XML;

$xml = simplexml_load_string($string);
foreach(
$xml->foo[0]->attributes() as $a => $b) {
   echo
$a,'="',$b,"\"\n";
}
?>

The above example will output:

name="one"
game="lonely"



add a noteadd a note User Contributed Notes
Identifies an element's attributes
There are no user contributed notes for this page.




<SimpleXMLElement->asXML()SimpleXMLElement->children()>
Last updated: Thu, 26 Jun 2008
show source | credits | sitemap | contact | advertising | mirror sites
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://phpbuilder.com/
Last updated: Tue Nov 1 20:20:59 2005 EST
Columns / Articles | Tips / Quickies | News | News Linking and RSS Feeds | Shared Code Library
Mail Archives | Support / Discussion Forums | Get Started! Links | Contribute! | Docs