# SPL Module Reference: format_xml

load "format_xml";

    A simple XML parser/dumper module

    This module implements simple XML parser and dumper functions.

builtin format_xml_parse(xmldata);
builtin format_xml_dump(xmltree);

object FormatXmlEx
{
var description;
}

builtin format_xml_parse(xmldata);

    This function returns a tree of ordered hashes. The keys in the ordered
    hashes are encoded as following:

    	A:<Name>
    		An attribute to this node.

    	C<n>
    		Character data. <n> is counting up from zero.

    	E<n>:<Name>
    		A child node (element) in the XML tree. <n> is counting up
    		from zero. So e.g. "E0:realname" is the 1st child element
    		of the type "realname".

    		This is an order hash containing attributes, child nodes
    		and character data again.

    Because the hash is ordered, it is possible to get the elements in the
    correct order by using 'foreach' loops or using the 'next' and 'prev'
    instructions, or directly address the elements. E.g.

    	var xmldata =
    	<><?xml version="1.0" ?>
    		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    		  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    		<html>
    		  <head>
    		    <meta name="Author" content="Clifford Wolf" />
    		    <title>This is a simple test HTML page.</title>
    		    <link rel="Index" href="index.html" />
    		  </head>
    		  <body>
    		    <h1>Nothing interesting here!</h1>
    		  </body>
    		</html>
    	</>;

    	var xmltree = format_xml_parse(xmldata);

    	debug xmltree.["E0:html"].["E0:head"].["E0:title"].["C0"];

builtin format_xml_dump(xmltree);

    Create an XML text from a data structure such as returned by format_xml_parse().

object FormatXmlEx

    An instance of this object is thrown on XML parser errors.

var FormatXmlEx.description;

    A description text describing the error.

Generated by SPLDOC. | http://www.clifford.at/spl/