php-doc-en/reference/dom/functions/dom-domdocument-createelementns.xml

157 lines
4.6 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.10 $ -->
<refentry id="function.dom-domdocument-createelementns">
<refnamediv>
<refname>DOMDocument->createElementNS()</refname>
<refpurpose>
Create new element node with an associated namespace
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<classsynopsis>
<ooclass><classname>DOMDocument</classname></ooclass>
<methodsynopsis>
<type>DOMElement</type><methodname>createElementNS</methodname>
<methodparam><type>string</type><parameter>namespaceURI</parameter></methodparam>
<methodparam><type>string</type><parameter>qualifiedName</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>value</parameter></methodparam>
</methodsynopsis>
</classsynopsis>
<para>
This function creates a new element node with an associated namespace.
&dom.node.inserted;
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>namespaceURI</parameter></term>
<listitem>
<para>
The URI of the namespace.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>qualifiedName</parameter></term>
<listitem>
<para>
The qualified name of the element, as <literal>prefix:tagname</literal>.
</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>
The new <classname>DOMElement</classname> or &false; if an error occured.
</para>
</refsect1>
<refsect1 role="exceptions">
&reftitle.exceptions;
<para>
<variablelist>
<varlistentry>
<term><constant>DOM_INVALID_CHARACTER_ERR</constant></term>
<listitem>
<para>
Raised if <parameter>qualifiedName</parameter> contains an invalid character.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>DOM_NAMESPACE_ERR</constant></term>
<listitem>
<para>
Raised if <parameter>qualifiedName</parameter> is a maformed qualified
name.
</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->createElementNS('http://www.example.com/XFoo', 'xfoo: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"?>
<xfoo:test xmlns:xfoo="http://www.example.com/XFoo">This is the root element!</xfoo: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-createelement" /></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
-->