\ArrayToXml
Array To XML conversion
- Author: SOFORT AG (integration@sofort.com)
- Copyright: 2010-2014 SOFORT AG
- License: Released under the GNU LESSER GENERAL PUBLIC LICENSE (Version 3)
Synopsis
class ArrayToXml
{
- // members
- private integer $_maxDepth = 4;
- private $_parsedData = NULL;
- // methods
- public ArrayToXml __construct()
- public static string render()
- public string toXml()
- private void _checkDepth()
- private SofortTag _createNode()
- private SofortText _createTextNode()
- private array _extractAttributesSection()
- private array _extractDataSection()
- private void _render()
- private int _renderNode()
Members
private
- $_maxDepth
—
int
Maximum allowed depth - $_parsedData
—
string
Represents the parsed array structure
Methods
private
- _checkDepth() — Checks if current depth is exceeded
- _createNode() — Creates a new XML node
- _createTextNode() — Creates a new text node
- _extractAttributesSection() — Extracts the attributes section from a XmlToArray'd structure
- _extractDataSection() — Extracts the data section from a XmlToArray'd structure
- _render() — Recursively renders a XmlToArray'd structure into an object notation
- _renderNode() — Renders a single Node of the structure
public
- __construct() — Loads array into XML representation.
- render() — Static entry point. Options are: - version: (default 1.0) version string to put in xml prolog - encoding: (default UTF-8) use the specified encoding - trim: (default true) Trim values - depth: (default 10) Maximum depth to parse the given array, throws exception when exceeded
- toXml() — Returns parsed array as XML structure Pass both params as null to exclude prologue <?xml version="version" encoding="encoding" ?>