SYNOPSISstring xmlTreePrintDoc(xmlDoc doc [, string encoding]
[, string options])
Parameters:
doc
- the xmlDoc
to be printedencoding
- the character encoding to use when serializing
the document. Defaults to UTF-8
.options
- the options to use when saving (see below)
Returns:
doc
DESCRIPTIONxmlTreePrintDoc()
returns the serialized, text version of the XML
document doc
.
The possible values for options
are:
INDENT
- add extra whitespace text nodes to indent the output.
EXAMPLE<$doc = (xmlTreeNewDoc( '1.0'))>
<$root = (xmlTreeNewElement($doc, 'top'))>
<$ret = (xmlTreeNewElement($root, 'item', 'Look at me!'))>
<$ret = (xmlTreeNewElement($root, 'item', 'Items ahoy!'))>
<$nested = (xmlTreeNewElement($root, 'nested'))>
<$ret = (xmlTreeNewElement($nested, 'item', 'Going deeper!'))>
<$output = (xmlTreePrintDoc($doc))>
default (no indent):
-------------
<fmt "%js" $output>
-------------
<$output = (xmlTreePrintDoc($doc, 'INDENT'))>
with indents:
-------------
<fmt "%js" $output>
-------------
Will produce:
default (no indent):
-------------
<?xml version="1.0"?>
<top><item>Look at me!</item><item>Items ahoy!</item>
<nested><item>Going deeper!</item></nested></top>
-------------
with indents:
-------------
<?xml version="1.0"?>
<top>
<item>Look at me!</item>
<item>Items ahoy!</item>
<nested>
<item>Going deeper!</item>
</nested>
</top>
-------------
Note that the "no indent" version isn't actually two lines, but only appears to due to line length wrapping in the documentation.
SEE ALSOxmlTreeSaveDoc