DomElement->get_attribute()

(no version information, might be only in CVS)

DomElement->get_attribute() --  与えられた属性の値を返す

説明

class DomElement {

string get_attribute ( string name )

}

現在の要素中の与えられた属性の値を返します。

PHP 4.3 以降、与えられた名前 name を持つ属性がない場合、空文字列が返されます。

パラメータ

name

検索する属性の名前。このパラメータは大文字小文字を区別します。

返り値

属性の名前を文字列として返す、もしくは与えられた名前 name を持つ属性がない場合、空文字列が返されます。

例 1. 属性の値を取得する

<?php

include("example.inc");

if (!
$dom = domxml_open_mem($xmlstr)) {
    echo
"Error while parsing the document\n";
    exit;
}

// chapter を取得する
$root = $dom->document_element();
echo
$root->get_attribute('language'); // en

?>

PHP 5 への移行

DOMElement->getAttribute() を使用してください。

参考

DomElement->get_attribute_node()
DomElement->set_attribute()