Forum und email

SimpleXMLElement->attributes()

(PHP 5 >= 5.0.1)

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

설명

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

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

Note: SimpleXML은 대부분의 메쏘드에 추가 반복자 속성 규칙을 가지고 있습니다. 이들은 var_dump()나 객체를 조사하는 어떠한 것으로도 볼 수 없습니다.

매개변수

ns

An optional namespace for the retrieved attributes

is_prefix

Default to FALSE

반환값

예제

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";
}
?>

위 예제의 출력:

name="one"
game="lonely"