mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Used the new documentation format in the documented functions
Documented, reviewed and added examples to DOMDocument->__construct(), createEle ment*, load, loadXML, save*. Also documented DOMDocument->xinclude() and found bug #31200 git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@175146 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
732d1b3d0d
commit
2b1af939e4
13 changed files with 1021 additions and 510 deletions
|
@ -1,34 +1,44 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<refentry id='function.dom-domattr-isId'>
|
||||
<refnamediv>
|
||||
<refname>DOMAttr->isId</refname>
|
||||
<refpurpose>
|
||||
Checks if attribute is a defined ID
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMAttr</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>bool</type>
|
||||
<methodname>isId</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
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>DOMAttr->isId() Example</title>
|
||||
<programlisting role="php">
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<refentry id='function.dom-domattr-isId'>
|
||||
<refnamediv>
|
||||
<refname>DOMAttr->isId</refname>
|
||||
<refpurpose>
|
||||
Checks if attribute is a defined ID
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMAttr</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>bool</type>
|
||||
<methodname>isId</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
This function checks if the attribute is a defined 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>
|
||||
</refsect1>
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.success;
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>DOMAttr->isId() Example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
@ -45,10 +55,11 @@ var_dump($attr->isId()); // bool(true)
|
|||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,27 +1,77 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<refentry id='function.dom-domdocument-construct'>
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->__construct</refname>
|
||||
<refpurpose>
|
||||
Creates a new DOMDocument object
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<constructorsynopsis>
|
||||
<methodname>__construct</methodname>
|
||||
<methodparam choice='opt'><type>string</type><parameter>version</parameter></methodparam>
|
||||
<methodparam choice='opt'><type>string</type><parameter>encoding</parameter></methodparam>
|
||||
</constructorsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Creates a new DOMDocument object.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id='function.dom-domdocument-construct'>
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->__construct</refname>
|
||||
<refpurpose>
|
||||
Creates a new DOMDocument object
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<constructorsynopsis>
|
||||
<methodname>__construct</methodname>
|
||||
<methodparam choice='opt'><type>string</type><parameter>version</parameter></methodparam>
|
||||
<methodparam choice='opt'><type>string</type><parameter>encoding</parameter></methodparam>
|
||||
</constructorsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Creates a new <classname>DOMDocument</classname> object.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>version</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The version number of the document as part of the XML declaration.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>encoding</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The encoding of the document as part of the XML declaration.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Creating a new DOMDocument</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$dom = new DOMDocument('1.0', 'iso-8859-1');
|
||||
|
||||
echo $dom->saveXML(); /* <?xml version="1.0" encoding="iso-8859-1"?> */
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><link linkend="function.dom-domimplementation-createdocument">DOMImplementation-createDocument()</link></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,40 +1,100 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<refentry id="function.dom-domdocument-createelement">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->createElement</refname>
|
||||
<refpurpose>Create new element node</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&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 returns a new instance of class
|
||||
<classname>DOMElement</classname>. The tag name of the element is the
|
||||
value of the name parameter. Optionally, a value for the new element may
|
||||
also be passed in. &dom.node.inserted;
|
||||
</para>
|
||||
<para>
|
||||
The return value is &false; if an error occurred.
|
||||
</para>
|
||||
<para>
|
||||
See also <link linkend="function.dom-domdocument-createelementns">DOMDocument->createElementNS()</link>,
|
||||
<link linkend="function.dom-domnode-appendchild">DOMNode->appendChild()</link>,
|
||||
<link linkend="function.dom-domdocument-createtextnode">DOMDocument->createTextNode()</link>,
|
||||
<link linkend="function.dom-domdocument-createcomment">DOMDocument->createComment()</link>,
|
||||
<link linkend="function.dom-domdocument-createattribute">DOMDocument->createAttribute()</link>,
|
||||
<link linkend="function.dom-domdocument-createprocessinginstruction">DOMDocument->createProcessingInstruction()</link>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<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 element node. &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="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><link linkend="function.dom-domdocument-createelementns">DOMDocument->createElementNS()</link></member>
|
||||
<member><link linkend="function.dom-domnode-appendchild">DOMNode->appendChild()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-createtextnode">DOMDocument->createTextNode()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-createcomment">DOMDocument->createComment()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-createattribute">DOMDocument->createAttribute()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-createprocessinginstruction">DOMDocument->createProcessingInstruction()</link></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,43 +1,112 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<refentry id="function.dom-domdocument-createelementns">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->createElementNS</refname>
|
||||
<refpurpose>
|
||||
Create new element node with an associated namespace
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&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 returns a new instance of class
|
||||
<classname>DOMElement</classname>. The tag name and prefix of the element
|
||||
is determined by the value of the passed parameter <parameter>qualifiedName</parameter>.
|
||||
The URI of the namespace is the value of the passed parameter
|
||||
<parameter>namespaceURI</parameter>. &dom.node.inserted;
|
||||
</para>
|
||||
<para>
|
||||
The return value is &false; if an error occurred.
|
||||
</para>
|
||||
<para>
|
||||
See also <link linkend="function.dom-domnode-appendchild">DOMNode->appendChild()</link>,
|
||||
<link linkend="function.dom-domdocument-createattributens">DOMDocument->createAttributeNS()</link>,
|
||||
<link linkend="function.dom-domdocument-createelement">DOMDocument->createElement()</link>,
|
||||
<link linkend="function.dom-domdocument-createattribute">DOMDocument->createAttribute()</link> and
|
||||
<link linkend="function.dom-domdocument-createcomment">DOMDocument->createComment()</link>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<refentry id="function.dom-domdocument-createelementns">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->createElementNS</refname>
|
||||
<refpurpose>
|
||||
Create new element node with an associated namespace
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&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>
|
||||
Returns a new instance of class <classname>DOMElement</classname> or &false;
|
||||
if an error occured.
|
||||
</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><link linkend="function.dom-domdocument-createelement">DOMDocument->createElement()</link></member>
|
||||
<member><link linkend="function.dom-domnode-appendchild">DOMNode->appendChild()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-createtextnode">DOMDocument->createTextNode()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-createcomment">DOMDocument->createComment()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-createattribute">DOMDocument->createAttribute()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-createprocessinginstruction">DOMDocument->createProcessingInstruction()</link></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,54 +1,78 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<refentry id="function.dom-domdocument-load">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->load</refname>
|
||||
<refpurpose>
|
||||
Load XML from a file
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>mixed</type>
|
||||
<methodname>load</methodname>
|
||||
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
The function parses the XML document in the file named
|
||||
<parameter>filename</parameter>. This function may also be called
|
||||
statically to load and create a <classname>DOMDocument</classname> object.
|
||||
The static invocation may be used when no
|
||||
<classname>DOMDocument</classname> properties need to be set prior to
|
||||
loading.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Creating a Document</title>
|
||||
<programlisting role="php">
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<refentry id="function.dom-domdocument-load">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->load</refname>
|
||||
<refpurpose>
|
||||
Load XML from a file
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>mixed</type>
|
||||
<methodname>load</methodname>
|
||||
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Loads an XML document from a file.
|
||||
</para>
|
||||
<para>
|
||||
This method may also be called statically to load and create a
|
||||
<classname>DOMDocument</classname> object. The static invocation may be
|
||||
used when no <classname>DOMDocument</classname> properties need to be set
|
||||
prior to loading.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>filename</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The path to the XML document.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Creating a Document</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = DOMDocument::load("filename.xml");
|
||||
print $doc->saveXML();
|
||||
$doc = DOMDocument::load('book.xml');
|
||||
echo $doc->saveXML();
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$doc->load("filename");
|
||||
print $doc->saveXML();
|
||||
$doc->load('book.xml');
|
||||
echo $doc->saveXML();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <link linkend="function.dom-domdocument-loadxml">DOMDocument->loadXML()</link>,
|
||||
<link linkend="function.dom-domdocument-save">DOMDocument->save()</link> and
|
||||
<link linkend="function.dom-domdocument-savexml">DOMDocument->saveXML()</link>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><link linkend="function.dom-domdocument-loadxml">DOMDocument->loadXML()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-save">DOMDocument->save()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-savexml">DOMDocument->saveXML()</link></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,53 +1,78 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<refentry id="function.dom-domdocument-loadxml">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->loadXML</refname>
|
||||
<refpurpose>
|
||||
Load XML from a string
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>mixed</type>
|
||||
<methodname>loadXML</methodname>
|
||||
<methodparam><type>string</type><parameter>source</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
The function parses the XML contained in the string <parameter>source</parameter>.
|
||||
This function may also be called statically to load and create a
|
||||
<classname>DOMDocument</classname> object. The static invocation may be
|
||||
used when no <classname>DOMDocument</classname> properties need to be
|
||||
set prior to loading.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Creating a Document</title>
|
||||
<programlisting role="php">
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<refentry id="function.dom-domdocument-loadxml">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->loadXML</refname>
|
||||
<refpurpose>
|
||||
Load XML from a string
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>mixed</type>
|
||||
<methodname>loadXML</methodname>
|
||||
<methodparam><type>string</type><parameter>source</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Loads an XML document from a string.
|
||||
</para>
|
||||
<para>
|
||||
This method may also be called statically to load and create a
|
||||
<classname>DOMDocument</classname> object. The static invocation may be
|
||||
used when no <classname>DOMDocument</classname> properties need to be set
|
||||
prior to loading.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>source</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The string containing the XML.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Creating a Document</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = DOMDocument::loadXML("<root><node/></root>");
|
||||
print $doc->saveXML();
|
||||
$doc = DOMDocument::loadXML('<root><node/></root>');
|
||||
echo $doc->saveXML();
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$doc->loadXML("<root><node/></root>");
|
||||
print $doc->saveXML();
|
||||
$doc->loadXML('<root><node/></root>');
|
||||
echo $doc->saveXML();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <link linkend="function.dom-domdocument-load">DOMDocument->load()</link>,
|
||||
<link linkend="function.dom-domdocument-save">DOMDocument->save()</link> and
|
||||
<link linkend="function.dom-domdocument-savexml">DOMDocument->saveXML()</link>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><link linkend="function.dom-domdocument-load">DOMDocument->load()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-save">DOMDocument->save()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-savexml">DOMDocument->saveXML()</link></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,55 +1,89 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<refentry id="function.dom-domdocument-save">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->save</refname>
|
||||
<refpurpose>
|
||||
Dumps the internal XML tree back into a file
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>int</type>
|
||||
<methodname>save</methodname>
|
||||
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Creates an XML document from the dom representation. The number of bytes
|
||||
written is returned. This function is usually called after building a new dom
|
||||
document from scratch as in the example below.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Creating a simple HTML document header</title>
|
||||
<programlisting role="php">
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<refentry id="function.dom-domdocument-save">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->save</refname>
|
||||
<refpurpose>
|
||||
Dumps the internal XML tree back into a file
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>mixed</type>
|
||||
<methodname>save</methodname>
|
||||
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Creates an XML document from the DOM representation. This function is usually
|
||||
called after building a new dom document from scratch as in the example below.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>filename</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The path to the saved XML document.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns the number of bytes written or &false; if an error occured.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Saving a DOM tree into a file</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument("1.0");
|
||||
$root = $doc->createElement("HTML");
|
||||
|
||||
$doc = new DOMDocument('1.0');
|
||||
// we want a nice output
|
||||
$doc->formatOutput = true;
|
||||
|
||||
$root = $doc->createElement('book');
|
||||
$root = $doc->appendChild($root);
|
||||
$head = $doc->createElement("HEAD");
|
||||
$head = $root->appendChild($head);
|
||||
$title = $doc->createElement("TITLE");
|
||||
$title = $head->appendChild($title);
|
||||
$text = $doc->createTextNode("This is the title");
|
||||
|
||||
$title = $doc->createElement('title');
|
||||
$title = $root->appendChild($title);
|
||||
|
||||
$text = $doc->createTextNode('This is the title');
|
||||
$text = $title->appendChild($text);
|
||||
$doc->save("/tmp/test.xml");
|
||||
|
||||
echo 'Wrote: ' . $doc->save("/tmp/test.xml") . ' bytes'; // Wrote: 72 bytes
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <link linkend="function.dom-domdocument-load">DOMDocument->load()</link>,
|
||||
<link linkend="function.dom-domdocument-loadxml">DOMDocument->loadXML()</link>
|
||||
and <link linkend="function.dom-domdocument-savexml">DOMDocument->saveXML()</link>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><link linkend="function.dom-domdocument-savexml">DOMDocument->saveXML()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-load">DOMDocument->load()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-loadxml">DOMDocument->loadXML()</link></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,57 +1,77 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<refentry id="function.dom-domdocument-savehtml">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->saveHTML</refname>
|
||||
<refpurpose>
|
||||
Dumps the internal document into a string using HTML formatting
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>string</type>
|
||||
<methodname>saveHTML</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Creates an HTML document from the dom representation. This function
|
||||
usually is called after building a new dom document from scratch
|
||||
as in the example below.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Creating a simple HTML document header</title>
|
||||
<programlisting role="php">
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<refentry id="function.dom-domdocument-savehtml">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->saveHTML</refname>
|
||||
<refpurpose>
|
||||
Dumps the internal document into a string using HTML formatting
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>string</type>
|
||||
<methodname>saveHTML</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Creates an HTML document from the DOM representation. This function is usually
|
||||
called after building a new dom document from scratch as in the example below.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns the HTML, or &false; if an error occured.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Saving a HTML tree into a string</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument("1.0");
|
||||
$root = $doc->createElement("HTML");
|
||||
|
||||
$doc = new DOMDocument('1.0');
|
||||
// we want a nice output
|
||||
$doc->formatOutput = true;
|
||||
|
||||
$root = $doc->createElement('html');
|
||||
$root = $doc->appendChild($root);
|
||||
$head = $doc->createElement("HEAD");
|
||||
|
||||
$head = $doc->createElement('head');
|
||||
$head = $root->appendChild($head);
|
||||
$title = $doc->createElement("TITLE");
|
||||
|
||||
$title = $doc->createElement('title');
|
||||
$title = $head->appendChild($title);
|
||||
$text = $doc->createTextNode("This is the title");
|
||||
|
||||
$text = $doc->createTextNode('This is the title');
|
||||
$text = $title->appendChild($text);
|
||||
echo "<PRE>";
|
||||
|
||||
echo $doc->saveHTML();
|
||||
echo "</PRE>";
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <link linkend="function.dom-domdocument-loadhtml">DOMDocument->loadHTML()</link>,
|
||||
<link linkend="function.dom-domdocument-loadhtmlfile">DOMDocument->loadHTMLFile()</link>
|
||||
and <link linkend="function.dom-domdocument-savehtmlfile">DOMDocument->saveHTMLFile()</link>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><link linkend="function.dom-domdocument-savehtmlfile">DOMDocument->saveHTMLFile()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-loadhtml">DOMDocument->loadHTML()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-loadhtmlfile">DOMDocument->loadHTMLFile()</link></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,55 +1,92 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<refentry id="function.dom-domdocument-savehtmlfile">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->saveHTMLFile</refname>
|
||||
<refpurpose>
|
||||
Dumps the internal document back into a file using HTML formatting
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>string</type>
|
||||
<methodname>saveHTMLFile</methodname>
|
||||
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Creates an HTML document from the dom representation. This function
|
||||
usually is called after building a new dom document from scratch
|
||||
as in the example below.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Creating a simple HTML document header</title>
|
||||
<programlisting role="php">
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<refentry id="function.dom-domdocument-savehtmlfile">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->saveHTML</refname>
|
||||
<refpurpose>
|
||||
Dumps the internal document into a file using HTML formatting
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>int</type>
|
||||
<methodname>saveHTMLFile</methodname>
|
||||
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Creates an HTML document from the DOM representation. This function is usually
|
||||
called after building a new dom document from scratch as in the example below.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>filename</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The path to the saved HTML document.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns the number of bytes written or &false; if an error occured.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Saving a HTML tree into a file</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument("1.0");
|
||||
$root = $doc->createElement("HTML");
|
||||
|
||||
$doc = new DOMDocument('1.0');
|
||||
// we want a nice output
|
||||
$doc->formatOutput = true;
|
||||
|
||||
$root = $doc->createElement('html');
|
||||
$root = $doc->appendChild($root);
|
||||
$head = $doc->createElement("HEAD");
|
||||
|
||||
$head = $doc->createElement('head');
|
||||
$head = $root->appendChild($head);
|
||||
$title = $doc->createElement("TITLE");
|
||||
|
||||
$title = $doc->createElement('title');
|
||||
$title = $head->appendChild($title);
|
||||
$text = $doc->createTextNode("This is the title");
|
||||
|
||||
$text = $doc->createTextNode('This is the title');
|
||||
$text = $title->appendChild($text);
|
||||
$doc->saveHTMLFile("/tmp/test.hmtl");
|
||||
|
||||
echo 'Wrote: ' . $doc->saveHTMLFile("/tmp/test.html") . ' bytes'; // Wrote: 129 bytes
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <link linkend="function.dom-domdocument-loadhtml">DOMDocument->loadHTML()</link>,
|
||||
<link linkend="function.dom-domdocument-loadhtmlfile">DOMDocument->loadHTMLFile()</link>
|
||||
and <link linkend="function.dom-domdocument-savehtml">DOMDocument->saveHTML()</link>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><link linkend="function.dom-domdocument-savehtml">DOMDocument->saveHTML()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-loadhtml">DOMDocument->loadHTML()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-loadhtmlfile">DOMDocument->loadHTMLFile()</link></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,56 +1,107 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<refentry id="function.dom-domdocument-savexml">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->saveXML</refname>
|
||||
<refpurpose>Dumps the internal XML tree back into a string</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>string</type>
|
||||
<methodname>saveXML</methodname>
|
||||
<methodparam choice="opt"><type>DOMNode</type><parameter>node</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Creates an XML document from the dom representation. This function is
|
||||
usually called after building a new dom document from scratch
|
||||
as in the example below. The
|
||||
<parameter>node</parameter> is used to output only the node rather than the entire document.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Creating a simple HTML document header</title>
|
||||
<programlisting role="php">
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<refentry id="function.dom-domdocument-savexml">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->saveXML</refname>
|
||||
<refpurpose>
|
||||
Dumps the internal XML tree back into a string
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>string</type>
|
||||
<methodname>saveXML</methodname>
|
||||
<methodparam choice="opt"><type>DOMNode</type><parameter>node</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Creates an XML document from the DOM representation. This function is usually
|
||||
called after building a new dom document from scratch as in the example below.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>node</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Use this parameter to output only a specific node without XML declaration
|
||||
rather than the entire document.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns the XML, or &false; if an error occured.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Saving a DOM tree into a file</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$doc = new DOMDocument("1.0");
|
||||
$root = $doc->createElement("HTML");
|
||||
|
||||
$doc = new DOMDocument('1.0');
|
||||
// we want a nice output
|
||||
$doc->formatOutput = true;
|
||||
|
||||
$root = $doc->createElement('book');
|
||||
$root = $doc->appendChild($root);
|
||||
$head = $doc->createElement("HEAD");
|
||||
$head = $root->appendChild($head);
|
||||
$title = $doc->createElement("TITLE");
|
||||
$title = $head->appendChild($title);
|
||||
$text = $doc->createTextNode("This is the title");
|
||||
|
||||
$title = $doc->createElement('title');
|
||||
$title = $root->appendChild($title);
|
||||
|
||||
$text = $doc->createTextNode('This is the title');
|
||||
$text = $title->appendChild($text);
|
||||
echo "<PRE>";
|
||||
echo htmlentities($doc->saveXML());
|
||||
echo "</PRE>";
|
||||
|
||||
echo "Retrieving all the document:\n";
|
||||
echo $doc->saveXML() . "\n";
|
||||
|
||||
echo "Retrieving only the title part:\n";
|
||||
echo $doc->saveXML($title);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <link linkend="function.dom-domdocument-load">DOMDocument->load()</link>,
|
||||
<link linkend="function.dom-domdocument-loadxml">DOMDocument->loadXML()</link>
|
||||
and <link linkend="function.dom-domdocument-save">DOMDocument->save()</link>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Retrieving all the document:
|
||||
<?xml version="1.0"?>
|
||||
<book>
|
||||
<title>This is the title</title>
|
||||
</book>
|
||||
|
||||
Retrieving only the head part:
|
||||
<title>This is the title</title>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><link linkend="function.dom-domdocument-save">DOMDocument->save()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-load">DOMDocument->load()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-loadxml">DOMDocument->loadXML()</link></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,33 +1,43 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<refentry id="function.dom-domdocument-validate">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->validate</refname>
|
||||
<refpurpose>
|
||||
Validates the document based on its DTD
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>bool</type>
|
||||
<methodname>validate</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Validates the document based on its DTD. &return.success;
|
||||
If the document have no DTD attached, this method will return &false;.
|
||||
</para>
|
||||
<para>
|
||||
You can also use the <literal>validateOnParse</literal> property of
|
||||
<classname>DOMDocument</classname> to make a DTD validation.
|
||||
</para>
|
||||
<example>
|
||||
<title>Example of DTD validation</title>
|
||||
<programlisting role="php">
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<refentry id="function.dom-domdocument-validate">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->validate</refname>
|
||||
<refpurpose>
|
||||
Validates the document based on its DTD
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>bool</type>
|
||||
<methodname>validate</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Validates the document based on its DTD.
|
||||
</para>
|
||||
<para>
|
||||
You can also use the <literal>validateOnParse</literal> property of
|
||||
<classname>DOMDocument</classname> to make a DTD validation.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.success;
|
||||
If the document have no DTD attached, this method will return &false;.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Example of DTD validation</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$dom = new DOMDocument;
|
||||
|
@ -37,11 +47,11 @@ if ($dom->validate()) {
|
|||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
You can also validate your XML file while loading it:
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
</programlisting>
|
||||
<para>
|
||||
You can also validate your XML file while loading it:
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$dom = new DOMDocument;
|
||||
|
@ -49,16 +59,22 @@ $dom->validateOnParse = true;
|
|||
$dom->Load('book.xml');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
See also <link linkend="function.dom-domdocument-schemavalidate">DOMDocument->schemaValidate()</link>,
|
||||
<link linkend="function.dom-domdocument-schemavalidatesource">DOMDocument->schemaValidateSource()</link>,
|
||||
<link linkend="function.dom-domdocument-relaxngvalidate">DOMDocument->relaxNGValidate()</link>,
|
||||
<link linkend="function.dom-domdocument-relaxngvalidatesource">DOMDocument->relaxNGValidateSource()</link>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><link linkend="function.dom-domdocument-schemavalidate">DOMDocument->schemaValidate()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-schemavalidatesource">DOMDocument->schemaValidateSource()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-relaxngvalidate">DOMDocument->relaxNGValidate()</link></member>
|
||||
<member><link linkend="function.dom-domdocument-relaxngvalidatesource">DOMDocument->relaxNGValidateSource()</link></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,27 +1,112 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<refentry id="function.dom-domdocument-xinclude">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->xinclude</refname>
|
||||
<refpurpose>
|
||||
Substitutes XIncludes in a DOMDocument Object
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>int</type>
|
||||
<methodname>xinclude</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Substitutes XIncludes in a DOMDocument Object.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<refentry id="function.dom-domdocument-xinclude">
|
||||
<refnamediv>
|
||||
<refname>DOMDocument->xinclude</refname>
|
||||
<refpurpose>
|
||||
Substitutes XIncludes in a DOMDocument Object
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMDocument</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>int</type>
|
||||
<methodname>xinclude</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
This method substitutes <ulink
|
||||
url="&url.xinclude.spec;">XIncludes</ulink> in a DOMDocument object.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
Due to libxml2 automatically resolving entities, this method will produce
|
||||
unexpected results if the included XML file have an attached DTD.
|
||||
</para>
|
||||
</note>
|
||||
</refsect1>
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns the number of XIncludes in the document.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>DOMDocument->xinclude() example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$xml = <<<EOD
|
||||
<?xml version="1.0" ?>
|
||||
<chapter xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<title>Books of the other guy..</title>
|
||||
<para>
|
||||
<xi:include href="book.xml">
|
||||
<xi:fallback>
|
||||
<error>xinclude: book.xml not found</error>
|
||||
</xi:fallback>
|
||||
</xi:include>
|
||||
</para>
|
||||
</chapter>
|
||||
EOD;
|
||||
|
||||
$dom = new DOMDocument;
|
||||
|
||||
// let's have a nice output
|
||||
$dom->preserveWhiteSpace = false;
|
||||
$dom->formatOutput = true;
|
||||
|
||||
// load the XML string defined above
|
||||
$dom->loadXML($xml);
|
||||
|
||||
// substitute xincludes
|
||||
$dom->xinclude();
|
||||
|
||||
echo $dom->saveXML();
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen role="xml">
|
||||
<![CDATA[
|
||||
<?xml version="1.0"?>
|
||||
<chapter xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<title>Books of the other guy..</title>
|
||||
<para>
|
||||
<row xml:base="/home/didou/book.xml">
|
||||
<entry>The Grapes of Wrath</entry>
|
||||
<entry>John Steinbeck</entry>
|
||||
<entry>en</entry>
|
||||
<entry>0140186409</entry>
|
||||
</row>
|
||||
<row xml:base="/home/didou/book.xml">
|
||||
<entry>The Pearl</entry>
|
||||
<entry>John Steinbeck</entry>
|
||||
<entry>en</entry>
|
||||
<entry>014017737X</entry>
|
||||
</row>
|
||||
<row xml:base="/home/didou/book.xml">
|
||||
<entry>Samarcande</entry>
|
||||
<entry>Amine Maalouf</entry>
|
||||
<entry>fr</entry>
|
||||
<entry>2253051209</entry>
|
||||
</row>
|
||||
</para>
|
||||
</chapter>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,32 +1,67 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<refentry id="function.dom-domxpath-query">
|
||||
<refnamediv>
|
||||
<refname>DOMXPath->query</refname>
|
||||
<refpurpose>
|
||||
Evaluates the given XPath expression
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMXPath</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>DOMNodeList</type>
|
||||
<methodname>query</methodname>
|
||||
<methodparam><type>string</type><parameter>expression</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>DOMNode</type><parameter>contextnode</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Returns a <classname>DOMNodeList</classname> containing all nodes matching
|
||||
the given XPath <parameter>expression</parameter>. Any expression which do
|
||||
not return nodes will return an empty <classname>DOMNodeList</classname>.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Getting all the english books</title>
|
||||
<programlisting role="php">
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<refentry id="function.dom-domxpath-query">
|
||||
<refnamediv>
|
||||
<refname>DOMXPath->query</refname>
|
||||
<refpurpose>
|
||||
Evaluates the given XPath expression
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<classsynopsis>
|
||||
<ooclass><classname>DOMXPath</classname></ooclass>
|
||||
<methodsynopsis>
|
||||
<type>DOMNodeList</type>
|
||||
<methodname>query</methodname>
|
||||
<methodparam><type>string</type><parameter>expression</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>DOMNode</type><parameter>contextnode</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
Excutes the given XPath <parameter>expression</parameter> and returns a
|
||||
set of nodes as result.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>expression</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The XPath expression to execute.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>contextnode</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The optional <parameter>contextnode</parameter> can be specified for
|
||||
doing relative XPath queries. By default, the queries are relative to
|
||||
the root element.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns a <classname>DOMNodeList</classname> containing all nodes matching
|
||||
the given XPath <parameter>expression</parameter>. Any expression which do
|
||||
not return nodes will return an empty <classname>DOMNodeList</classname>.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Getting all the english books</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
@ -50,25 +85,19 @@ foreach ($entries as $entry) {
|
|||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Found The Grapes of Wrath, by John Steinbeck
|
||||
Found The Pearl, by John Steinbeck
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</screen>
|
||||
<para>
|
||||
The optional <parameter>contextnode</parameter> can be specified for doing
|
||||
relative XPath queries. By default, the queries are relative to the root
|
||||
element. Knowing that, we can rewrite our previous example as follow:
|
||||
We can also use the <parameter>contextnode</parameter> parameter to shorten
|
||||
our expression:
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Using the context node</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
@ -92,11 +121,11 @@ foreach ($entries as $entry) {
|
|||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
Loading…
Reference in a new issue