Tutorial Extension  1.0.0
SellerDeck Extensions - Tutorial Extension
Static Public Member Functions | List of all members
XML2Array Class Reference

Static Public Member Functions

static init ($version= '1.0', $encoding= 'UTF-8', $format_output=true)
 
static & createArray ($input_xml)
 

Detailed Description

Definition at line 24 of file XML2Array.php.

Member Function Documentation

static& createArray (   $input_xml)
static

Convert an XML to Array

Parameters
string$node_name- name of the root node to be converted
array$arr- aray to be converterd
Returns
DOMDocument

Definition at line 49 of file XML2Array.php.

50  {
51  $xml = self::getXMLRoot();
52  if (is_string($input_xml))
53  {
54  $parsed = $xml->loadXML($input_xml);
55  if (!$parsed)
56  {
57  throw new \Exception('[XML2Array] Error parsing the XML string.');
58  }
59  }
60  else
61  {
62  if (get_class($input_xml) != 'DOMDocument')
63  {
64  throw new \Exception('[XML2Array] The input XML object should be of type: DOMDocument.');
65  }
66  $xml = self::$xml = $input_xml;
67  }
68  $array[$xml->documentElement->tagName] = self::convert($xml->documentElement);
69  self::$xml = null; // clear the xml node in the class for 2nd time use.
70  return $array;
71  }
static init (   $version = '1.0',
  $encoding = 'UTF-8',
  $format_output = true 
)
static

Initialize the root XML node [optional]

Parameters
$version
$encoding
$format_output

Definition at line 36 of file XML2Array.php.

37  {
38  self::$xml = new \DOMDocument($version, $encoding);
39  self::$xml->formatOutput = $format_output;
40  self::$encoding = $encoding;
41  }

The documentation for this class was generated from the following file: