DOMElement->getAttribute()
DOMElement->getAttribute() — 属性の値を返す
説明
class DOMElement {string getAttribute ( string name )
} 現在のノードから、名前が name である 属性の値を取得します。
パラメータ
- name
-
属性の名前。
返り値
属性の値、あるいは name に対応する属性が 見つからなかった場合には空の文字列を返します。参考
DOMElement->hasAttribute() |
DOMElement->setAttribute() |
DOMElement->removeAttribute() |
DomElement->get_attribute()
DomElement->get_attribute() — 与えられた属性の値を返す
説明
class DomElement {string get_attribute ( string name )
} 現在の要素中の与えられた属性の値を返します。
PHP 4.3 以降、与えられた名前 name を持つ属性がない場合、空文字列が返されます。
パラメータ
- name
-
検索する属性の名前。このパラメータは大文字小文字を区別します。
返り値
属性の名前を文字列として返す、もしくは与えられた名前 name を持つ属性がない場合、空文字列が返されます。例
例 529. 属性の値を取得する
<?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() |
- DOMElement->getAttribute()のページへのリンク