From 75bff3178a5164ed205bfeb0b83d92cb70e27a25 Mon Sep 17 00:00:00 2001 From: Mehdi Achour Date: Mon, 20 Dec 2004 03:10:23 +0000 Subject: [PATCH] document DOMAttr->isId() and DOMDocument->getElementById() git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@175105 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/dom/functions/dom-domattr-isid.xml | 31 ++++++++++++++- .../dom-domdocument-getelementbyid.xml | 38 +++++++++++++++++-- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/reference/dom/functions/dom-domattr-isid.xml b/reference/dom/functions/dom-domattr-isid.xml index 664d63c918..2a7691641d 100644 --- a/reference/dom/functions/dom-domattr-isid.xml +++ b/reference/dom/functions/dom-domattr-isid.xml @@ -1,5 +1,5 @@ - + DOMAttr->isId @@ -18,8 +18,35 @@ - This function checks if the attribute is a defined ID. + This function checks if the attribute is a defined ID. &return.success; + + According to the DOM standard this requires a DTD which defines the + attribute ID to be of type ID. You need to validate your document with + DOMDocument->validate() + or DOMDocument::validateOnParse before using this function. + + + DOMDocument->getElementById() Example + +validateOnParse = true; +$doc->Load('book.xml'); + +// We retrieve the attribute named id of the chapter element +$attr = $doc->getElementsByTagName('chapter')->item(0)->getAttributeNode('id'); + +var_dump($attr->isId()); // bool(true) + +?> +]]> + + diff --git a/reference/dom/functions/dom-domdocument-getelementbyid.xml b/reference/dom/functions/dom-domdocument-getelementbyid.xml index 5a3ecc5940..1cc7b6d9b0 100644 --- a/reference/dom/functions/dom-domdocument-getelementbyid.xml +++ b/reference/dom/functions/dom-domdocument-getelementbyid.xml @@ -1,5 +1,5 @@ - + DOMDocument->getElementById @@ -18,8 +18,40 @@ This function is similar to DOMDocument->getElementsByTagName() - but searches for an element with a given id. According to the DOM standard - this requires a DTD which defines the attribute ID to be of type ID. + but searches for an element with a given id. + + + According to the DOM standard this requires a DTD which defines the + attribute ID to be of type ID. You need to validate your document with + DOMDocument->validate() + or DOMDocument::validateOnParse before using this function. + + + DOMDocument->getElementById() Example + +validateOnParse = true; +$doc->Load('book.xml'); + +echo "The element whose id is books is: " . $doc->getElementById('books')->tagName . "\n"; + +?> +]]> + + &example.outputs; + + + + + + See also DOMDocument->getElementsByTagName().