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.savexml" xmlns="http://docbook.org/ns/docbook">
|
2004-12-20 15:57:49 +00:00
|
|
|
<refnamediv>
|
2007-12-16 13:18:08 +00:00
|
|
|
<refname>DOMDocument::saveXML</refname>
|
2004-12-20 15:57:49 +00:00
|
|
|
<refpurpose>
|
2004-12-20 17:03:59 +00:00
|
|
|
Dumps the internal XML tree back into a string
|
2004-12-20 15:57:49 +00:00
|
|
|
</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>string</type><methodname>DOMDocument::saveXML</methodname>
|
2007-12-16 13:18:08 +00:00
|
|
|
<methodparam choice="opt"><type>DOMNode</type><parameter>node</parameter></methodparam>
|
2018-11-27 11:34:39 +00:00
|
|
|
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>0</initializer></methodparam>
|
2007-12-16 13:18:08 +00:00
|
|
|
</methodsynopsis>
|
2004-12-20 15:57:49 +00:00
|
|
|
<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>
|
2005-09-08 12:02:24 +00:00
|
|
|
|
2004-12-20 15:57:49 +00:00
|
|
|
<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>
|
2005-09-08 12:02:24 +00:00
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>options</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Additional Options. Currently only <link
|
|
|
|
linkend="libxml.constants">LIBXML_NOEMPTYTAG</link> is supported.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2004-12-20 15:57:49 +00:00
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2005-09-08 12:02:24 +00:00
|
|
|
|
2004-12-20 15:57:49 +00:00
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
2005-02-14 04:13:17 +00:00
|
|
|
Returns the XML, or &false; if an error occurred.
|
2004-12-20 15:57:49 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
2006-09-06 20:40:41 +00:00
|
|
|
<refsect1 role="errors">
|
|
|
|
&reftitle.errors;
|
2004-12-31 11:49:57 +00:00
|
|
|
<para>
|
2005-01-02 15:36:00 +00:00
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>DOM_WRONG_DOCUMENT_ERR</constant></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Raised if <parameter>node</parameter> is from another document.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
2004-12-31 11:49:57 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
2005-09-08 12:02:24 +00:00
|
|
|
|
|
|
|
<refsect1 role="changelog">
|
|
|
|
&reftitle.changelog;
|
|
|
|
<para>
|
|
|
|
<informaltable>
|
|
|
|
<tgroup cols="2">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry>&Version;</entry>
|
|
|
|
<entry>&Description;</entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<row>
|
|
|
|
<entry>5.1.0</entry>
|
|
|
|
<entry>
|
|
|
|
Added the <parameter>options</parameter> parameter
|
|
|
|
</entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</informaltable>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
2004-12-20 15:57:49 +00:00
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
|
|
<example>
|
2004-12-20 17:03:59 +00:00
|
|
|
<title>Saving a DOM tree into a string</title>
|
2004-12-20 15:57:49 +00:00
|
|
|
<programlisting role="php">
|
2004-05-09 15:07:48 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
2004-12-20 15:57:49 +00:00
|
|
|
|
|
|
|
$doc = new DOMDocument('1.0');
|
|
|
|
// we want a nice output
|
|
|
|
$doc->formatOutput = true;
|
|
|
|
|
|
|
|
$root = $doc->createElement('book');
|
2004-05-09 15:07:48 +00:00
|
|
|
$root = $doc->appendChild($root);
|
2004-12-20 15:57:49 +00:00
|
|
|
|
|
|
|
$title = $doc->createElement('title');
|
|
|
|
$title = $root->appendChild($title);
|
|
|
|
|
|
|
|
$text = $doc->createTextNode('This is the title');
|
2004-05-09 15:07:48 +00:00
|
|
|
$text = $title->appendChild($text);
|
2004-12-20 15:57:49 +00:00
|
|
|
|
2006-04-17 12:59:17 +00:00
|
|
|
echo "Saving all the document:\n";
|
2004-12-20 15:57:49 +00:00
|
|
|
echo $doc->saveXML() . "\n";
|
|
|
|
|
2006-04-17 12:59:17 +00:00
|
|
|
echo "Saving only the title part:\n";
|
2004-12-20 15:57:49 +00:00
|
|
|
echo $doc->saveXML($title);
|
|
|
|
|
2004-05-09 15:07:48 +00:00
|
|
|
?>
|
|
|
|
]]>
|
2004-12-20 15:57:49 +00:00
|
|
|
</programlisting>
|
|
|
|
&example.outputs;
|
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
2006-04-17 12:59:17 +00:00
|
|
|
Saving all the document:
|
2004-12-20 15:57:49 +00:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<book>
|
|
|
|
<title>This is the title</title>
|
|
|
|
</book>
|
|
|
|
|
2006-04-17 12:59:17 +00:00
|
|
|
Saving only the title part:
|
2004-12-20 15:57:49 +00:00
|
|
|
<title>This is the title</title>
|
|
|
|
]]>
|
|
|
|
</screen>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
|
|
|
<para>
|
|
|
|
<simplelist>
|
2009-06-08 21:01:23 +00:00
|
|
|
<member><methodname>DOMDocument::save</methodname></member>
|
|
|
|
<member><methodname>DOMDocument::load</methodname></member>
|
|
|
|
<member><methodname>DOMDocument::loadXML</methodname></member>
|
2004-12-20 15:57:49 +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
|
|
|
|
-->
|