Skip to content

Commit f668666

Browse files
committed
Merge pull request #3 from muttley73/master
Set a prefix for attributes name.
2 parents 21249c9 + dda8093 commit f668666

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

LSS/XML2Array.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
class XML2Array {
4545

4646
private static $xml = null;
47-
private static $encoding = 'UTF-8';
47+
private static $encoding = 'UTF-8';
48+
private static $prefix_attributes = '@';
4849

4950
/**
5051
* Initialize the root XML node [optional]
@@ -92,7 +93,7 @@ private static function &convert($node) {
9293

9394
switch ($node->nodeType) {
9495
case XML_CDATA_SECTION_NODE:
95-
$output['@cdata'] = trim($node->textContent);
96+
$output[static::$prefix_attributes.'cdata'] = trim($node->textContent);
9697
break;
9798

9899
case XML_TEXT_NODE:
@@ -142,9 +143,9 @@ private static function &convert($node) {
142143
}
143144
// if its an leaf node, store the value in @value instead of directly storing it.
144145
if(!is_array($output)) {
145-
$output = array('@value' => $output);
146+
$output = array(static::$prefix_attributes.'value' => $output);
146147
}
147-
$output['@attributes'] = $a;
148+
$output[static::$prefix_attributes.'attributes'] = $a;
148149
}
149150
break;
150151
}

0 commit comments

Comments
 (0)