didou           Sun Dec 19 22:10:23 2004 EDT

  Modified files:              
    /phpdoc/en/reference/dom/functions  dom-domattr-isid.xml 
                                        dom-domdocument-getelementbyid.xml 
  Log:
  document DOMAttr->isId() and DOMDocument->getElementById()
  
http://cvs.php.net/diff.php/phpdoc/en/reference/dom/functions/dom-domattr-isid.xml?r1=1.4&r2=1.5&ty=u
Index: phpdoc/en/reference/dom/functions/dom-domattr-isid.xml
diff -u phpdoc/en/reference/dom/functions/dom-domattr-isid.xml:1.4 
phpdoc/en/reference/dom/functions/dom-domattr-isid.xml:1.5
--- phpdoc/en/reference/dom/functions/dom-domattr-isid.xml:1.4  Fri Dec 17 
10:16:13 2004
+++ phpdoc/en/reference/dom/functions/dom-domattr-isid.xml      Sun Dec 19 
22:10:23 2004
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
   <refentry id='function.dom-domattr-isId'>
    <refnamediv>
     <refname>DOMAttr->isId</refname>
@@ -18,8 +18,35 @@
      </methodsynopsis>
     </classsynopsis>
     <para>
-     This function checks if the attribute is a defined ID.
+     This function checks if the attribute is a defined ID. &return.success;
     </para>
+    <para>
+     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
+     <link 
linkend="function.dom-domdocument-validate">DOMDocument->validate()</link> 
+     or <literal>DOMDocument::validateOnParse</literal> before using this 
function.
+    </para>
+    <example>
+     <title>DOMDocument->getElementById() Example</title>
+     <programlisting role="php">
+<![CDATA[
+<?php
+
+$doc = new DomDocument;
+
+// We need to validate our document before refering to the id
+$doc->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)
+
+?>
+]]>
+     </programlisting>
+    </example>
    </refsect1>
   </refentry>
 
http://cvs.php.net/diff.php/phpdoc/en/reference/dom/functions/dom-domdocument-getelementbyid.xml?r1=1.5&r2=1.6&ty=u
Index: phpdoc/en/reference/dom/functions/dom-domdocument-getelementbyid.xml
diff -u 
phpdoc/en/reference/dom/functions/dom-domdocument-getelementbyid.xml:1.5 
phpdoc/en/reference/dom/functions/dom-domdocument-getelementbyid.xml:1.6
--- phpdoc/en/reference/dom/functions/dom-domdocument-getelementbyid.xml:1.5    
Fri Dec 17 10:11:30 2004
+++ phpdoc/en/reference/dom/functions/dom-domdocument-getelementbyid.xml        
Sun Dec 19 22:10:23 2004
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.5 $ -->
+<!-- $Revision: 1.6 $ -->
   <refentry id="function.dom-domdocument-getelementbyid">
    <refnamediv>
     <refname>DOMDocument->getElementById</refname>
@@ -18,8 +18,40 @@
     <para>
      This function is similar to
      <link 
linkend="function.dom-domdocument-getelementsbytagname">DOMDocument->getElementsByTagName()</link>
 
-     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.
+    </para>
+    <para>
+     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
+     <link 
linkend="function.dom-domdocument-validate">DOMDocument->validate()</link> 
+     or <literal>DOMDocument::validateOnParse</literal> before using this 
function.
+    </para>
+    <example>
+     <title>DOMDocument->getElementById() Example</title>
+     <programlisting role="php">
+<![CDATA[
+<?php
+
+$doc = new DomDocument;
+
+// We need to validate our document before refering to the id
+$doc->validateOnParse = true;
+$doc->Load('book.xml');
+
+echo "The element whose id is books is: " . 
$doc->getElementById('books')->tagName . "\n";
+
+?>
+]]>
+     </programlisting>
+     &example.outputs;
+     <screen>
+<![CDATA[
+The element whose id is books is: chapter
+]]>
+     </screen>
+    </example>
+    <para>
+     See also <link 
linkend="function.dom-domdocument-getelementsbytagname">DOMDocument->getElementsByTagName()</link>.
 
     </para>
    </refsect1>
   </refentry>

Reply via email to