2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 06:52:11 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-12-16 13:18:08 +00:00
|
|
|
<refentry xml:id="domdocument.getelementbyid" xmlns="http://docbook.org/ns/docbook">
|
2004-12-31 11:49:57 +00:00
|
|
|
<refnamediv>
|
2007-12-16 13:18:08 +00:00
|
|
|
<refname>DOMDocument::getElementById</refname>
|
2004-12-31 11:49:57 +00:00
|
|
|
<refpurpose>Searches for an element with a certain id</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2007-12-16 13:18:08 +00:00
|
|
|
<methodsynopsis>
|
2013-06-18 05:36:30 +00:00
|
|
|
<modifier>public</modifier> <type>DOMElement</type><methodname>DOMDocument::getElementById</methodname>
|
2007-12-16 13:18:08 +00:00
|
|
|
<methodparam><type>string</type><parameter>elementId</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
2004-12-31 11:49:57 +00:00
|
|
|
<para>
|
|
|
|
This function is similar to
|
2007-12-16 13:18:08 +00:00
|
|
|
<xref linkend="domdocument.getelementsbytagname" /> but
|
2004-12-31 11:49:57 +00:00
|
|
|
searches for an element with a given id.
|
|
|
|
</para>
|
|
|
|
<para>
|
2006-12-29 00:40:54 +00:00
|
|
|
For this function to work, you will need either to set some ID attributes
|
2007-12-16 13:18:08 +00:00
|
|
|
with <xref linkend="domelement.setidattribute" />
|
2006-12-29 00:40:54 +00:00
|
|
|
or a DTD which defines an attribute to be of type ID.
|
|
|
|
In the later case, you will need to validate your document with
|
2007-12-16 13:18:08 +00:00
|
|
|
<xref linkend="domdocument.validate" />
|
2012-01-12 05:58:52 +00:00
|
|
|
or <link
|
|
|
|
linkend="domdocument.props.validateonparse">DOMDocument::$validateOnParse</link> before using this function.
|
2004-12-31 11:49:57 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>elementId</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The unique id value for an element.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
|
|
|
Returns the <classname>DOMElement</classname> or &null; if the element is
|
|
|
|
not found.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<example>
|
2012-01-12 05:58:52 +00:00
|
|
|
<title>DOMDocument::getElementById() Example</title>
|
2012-07-27 12:09:35 +00:00
|
|
|
&dom.book.example;
|
2004-12-31 11:49:57 +00:00
|
|
|
<programlisting role="php">
|
2004-12-20 03:10:23 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$doc = new DomDocument;
|
|
|
|
|
|
|
|
// We need to validate our document before refering to the id
|
|
|
|
$doc->validateOnParse = true;
|
|
|
|
$doc->Load('book.xml');
|
|
|
|
|
2012-07-27 12:09:35 +00:00
|
|
|
echo "The element whose id is 'php-basics' is: " . $doc->getElementById('php-basics')->tagName . "\n";
|
2004-12-20 03:10:23 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
]]>
|
2004-12-31 11:49:57 +00:00
|
|
|
</programlisting>
|
|
|
|
&example.outputs;
|
|
|
|
<screen>
|
2004-12-20 03:10:23 +00:00
|
|
|
<![CDATA[
|
2012-07-27 12:09:35 +00:00
|
|
|
The element whose id is 'php-basics' is: book
|
2004-12-20 03:10:23 +00:00
|
|
|
]]>
|
2004-12-31 11:49:57 +00:00
|
|
|
</screen>
|
|
|
|
</example>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
|
|
|
<para>
|
|
|
|
<simplelist>
|
2009-06-08 21:01:23 +00:00
|
|
|
<member><methodname>DOMDocument::getElementsByTagName</methodname></member>
|
2004-12-31 11:49:57 +00:00
|
|
|
</simplelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2004-05-09 15:07:48 +00:00
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2004-05-09 15:07:48 +00:00
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|