<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
<refentry id="function.dom-domdocument-createelement">
 <refnamediv>
  <refname>DOMDocument->createElement()</refname>
  <refpurpose>Create new element node</refpurpose>
 </refnamediv>
 <refsect1 role="description">
  &reftitle.description;
  <classsynopsis>
   <ooclass><classname>DOMDocument</classname></ooclass>
   <methodsynopsis>
    <type>DOMElement</type><methodname>createElement</methodname>
    <methodparam><type>string</type><parameter>name</parameter></methodparam>
    <methodparam choice="opt"><type>string</type><parameter>value</parameter></methodparam>
   </methodsynopsis>
  </classsynopsis>
  <para>
   This function creates a new instance of class
   <classname>DOMElement</classname>. &dom.node.inserted;
  </para>
 </refsect1>
 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>name</parameter></term>
     <listitem>
      <para>
       The tag name of the element.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>value</parameter></term>
     <listitem>
      <para>
       The value of the element. By default, an empty element will be created.
       You can also set the value later with <literal>DOMElement->nodeValue</literal>.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>
 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns a new instance of class <classname>DOMElement</classname> or &false;
   if an error occured.
  </para>
 </refsect1>
 <refsect1 role="errors">
  &reftitle.errors;
  <para>
   <variablelist>
    <varlistentry>
     <term><constant>DOM_INVALID_CHARACTER_ERR</constant></term>
     <listitem>
      <para>
       Raised if <parameter>name</parameter> contains an invalid character.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>
 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title>Creating a new element and inserting it as root</title>
    <programlisting role="php">
<![CDATA[
<?php

$dom = new DOMDocument('1.0', 'iso-8859-1');

$element = $dom->createElement('test', 'This is the root element!');

// We insert the new element as root (child of the document)
$dom->appendChild($element);

echo $dom->saveXML();
?>
]]>
    </programlisting>
    &example.outputs;
    <screen role="xml">
<![CDATA[
<?xml version="1.0" encoding="iso-8859-1"?>
<test>This is the root element!</test>
]]>
    </screen>
   </example>
  </para>
 </refsect1>
 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><xref linkend="function.dom-domnode-appendchild" /></member>
    <member><xref linkend="function.dom-domdocument-createattribute" /></member>
    <member><xref linkend="function.dom-domdocument-createattributens" /></member>
    <member><xref linkend="function.dom-domdocument-createcdatasection" /></member>
    <member><xref linkend="function.dom-domdocument-createcomment" /></member>
    <member><xref linkend="function.dom-domdocument-createdocumentfragment" /></member>
    <member><xref linkend="function.dom-domdocument-createelementns" /></member>
    <member><xref linkend="function.dom-domdocument-createentityreference" /></member>
    <member><xref linkend="function.dom-domdocument-createprocessinginstruction" /></member>
    <member><xref linkend="function.dom-domdocument-createtextnode" /></member>
   </simplelist>
  </para>
 </refsect1>
</refentry>

<!-- 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
sgml-default-dtd-file:"../../../../manual.ced"
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
-->