Skip to content

Commit ecffd41

Browse files
authored
Merge pull request #5 from justplaymore/patch-1
Update XML2Array.php
2 parents 6a7a621 + 35b7c63 commit ecffd41

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

LSS/XML2Array.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343

4444
class XML2Array {
4545

46-
private static $xml = null;
47-
private static $encoding = 'UTF-8';
48-
private static $prefix_attributes = '@';
46+
protected static $xml = null;
47+
protected static $encoding = 'UTF-8';
48+
protected static $prefix_attributes = '@';
4949

5050
/**
5151
* Initialize the root XML node [optional]
@@ -62,13 +62,14 @@ public static function init($version = '1.0', $encoding = 'UTF-8', $format_outpu
6262
/**
6363
* Convert an XML to Array
6464
* @param string $node_name - name of the root node to be converted
65+
* @param int - Bitwise OR of the libxml option constants see @link http://php.net/manual/zh/libxml.constants.php
6566
* @param array $arr - aray to be converterd
6667
* @return DOMDocument
6768
*/
68-
public static function &createArray($input_xml) {
69+
public static function &createArray($input_xml, $options = 0) {
6970
$xml = self::getXMLRoot();
7071
if(is_string($input_xml)) {
71-
$parsed = $xml->loadXML($input_xml);
72+
$parsed = $xml->loadXML($input_xml, $options);
7273
if(!$parsed) {
7374
throw new Exception('[XML2Array] Error parsing the XML string.');
7475
}
@@ -88,7 +89,7 @@ public static function &createArray($input_xml) {
8889
* @param mixed $node - XML as a string or as an object of DOMDocument
8990
* @return mixed
9091
*/
91-
private static function &convert($node) {
92+
protected static function &convert($node) {
9293
$output = array();
9394

9495
switch ($node->nodeType) {
@@ -155,7 +156,7 @@ private static function &convert($node) {
155156
/*
156157
* Get the root XML node, if there isn't one, create it.
157158
*/
158-
private static function getXMLRoot(){
159+
protected static function getXMLRoot(){
159160
if(empty(self::$xml)) {
160161
self::init();
161162
}

0 commit comments

Comments
 (0)