« Dom\Attr
Dom\Attr::rename »

Dom\Attr::isId

(PHP 8 >= 8.4.0)

Dom\Attr::isId — 属性が定義済みの ID かどうかを調べる

説明

public function Dom\Attr::isId(): bool

この関数は、属性が定義済みの ID かどうかを調べます。

DOM 標準によると、属性ID を ID型 として定義する DTD が必要です。 このメソッドを利用するには、 オプションとしてLIBXML_DTDVALIDを渡して、 解析時にドキュメントを検証しなければいけません。

パラメータ

この関数にはパラメータはありません。

戻り値

この属性が定義済みのIDであれば、true を返します。 それ以外の場合、false を返します。

例

例1 Dom\Attr::isId() の例

<?php

// We need to validate our document before referring to the id
$doc = Dom\XMLDocument::createFromFile('examples/book-docbook.xml', LIBXML_DTDVALID);

// We retrieve the attribute named id of the chapter element
$attr = $doc->getElementsByTagName('chapter')->item(0)->getAttributeNode('id');

var_dump($attr->isId()); // bool(true)

?>
関連キーワード:
Attr   属性   isId   chapter   attr   rename   解析   ドキュメント   検証   need   validate   document   before   referring   XMLDocument   createFromFile   examples   book   docbook   retrieve   attribute   named   element   getElementsByTagName   item
関連する関数・ページ:
class.dom-attr   domattr.isid   dom-attr.rename   function.dom-ns-import-simplexml   domelement.setidattributenode   domelement.setidattributens