xmlTreePrintDoc

SYNOPSIS

string xmlTreePrintDoc(xmlDoc doc [, string encoding]
                           [, string options])

Parameters:

  • doc - the xmlDoc to be printed

  • encoding - the character encoding to use when serializing the document. Defaults to UTF-8.

  • options - the options to use when saving (see below)

Returns:

  • the serialized string of doc


DESCRIPTION
xmlTreePrintDoc() 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 ALSO
xmlTreeSaveDoc


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.