Open jadark opened 6 years ago
Hello @jadark,
This issue was resolve with follow modifications in simplexml.class.php
:
Change initialization for var $evalCode = ''
to var $evalCode = array()
Add at the end in the function xml_reorganize
the follow line $this->result = array('@attributes' => array());
before eval($this->evalCode);
The final function is:
function xml_reorganize($array)
{
$count = count($array);
$repeat = $this->xml_tags($array);
$repeatedone = false;
$tags = array();
$k = 0;
for ($i = 0; $i < $count; $i++)
{
switch ($array[$i]['type']) {
case 'open':
array_push($tags, $array[$i]['tag']);
if ($i > 0 && ($array[$i]['tag'] == $array[$i-1]['tag']) && ($array[$i-1]['type'] == 'close'))
$k++;
if (isset($array[$i]['value']) && ($array[$i]['value'] || !$this->skip_empty_values))
{
array_push($tags, '@content');
$this->array_insert(count($tags), $tags, $array[$i]['value'], "open");
array_pop($tags);
}
if (in_array($array[$i]['tag'] . $array[$i]['level'], $repeat)) {
if (($repeatedone == $array[$i]['tag'] . $array[$i]['level']) && ($repeatedone))
{
array_push($tags, strval($k++));
}
else
{
$repeatedone = $array[$i]['tag'] . $array[$i]['level'];
array_push($tags, strval($k));
}
}
if (isset($array[$i]['attributes']) && $array[$i]['attributes'] && $array[$i]['level'] != $this->ignore_level) {
array_push($tags, '@attributes');
foreach ($array[$i]['attributes'] as $attrkey => $attr)
{
array_push($tags, $attrkey);
$this->array_insert(count($tags), $tags, $attr, "open");
array_pop($tags);
}
array_pop($tags);
}
break;
case 'close':
array_pop($tags);
if (in_array($array[$i]['tag'] . $array[$i]['level'], $repeat))
{
if ($repeatedone == $array[$i]['tag'] . $array[$i]['level'])
{
array_pop($tags);
}
else
{
$repeatedone = $array[$i + 1]['tag'] . $array[$i + 1]['level'];
array_pop($tags);
}
}
break;
case 'complete':
array_push($tags, $array[$i]['tag']);
if (in_array($array[$i]['tag'] . $array[$i]['level'], $repeat))
{
if ($repeatedone == $array[$i]['tag'] . $array[$i]['level'] && $repeatedone)
{
array_push($tags, strval($k));
}
else
{
$repeatedone = $array[$i]['tag'] . $array[$i]['level'];
array_push($tags, strval($k));
}
}
if (isset($array[$i]['value']) && ($array[$i]['value'] || !$this->skip_empty_values))
{
if (isset($array[$i]['attributes']) && $array[$i]['attributes'])
{
array_push($tags, '@content');
$this->array_insert(count($tags), $tags, $array[$i]['value'], "complete");
array_pop($tags);
}
else
{
$this->array_insert(count($tags), $tags, $array[$i]['value'], "complete");
}
}
if (isset($array[$i]['attributes']) && $array[$i]['attributes'])
{
array_push($tags, '@attributes');
foreach ($array[$i]['attributes'] as $attrkey => $attr)
{
array_push($tags, $attrkey);
$this->array_insert(count($tags), $tags, $attr, "complete");
array_pop($tags);
}
array_pop($tags);
}
if (in_array($array[$i]['tag'] . $array[$i]['level'], $repeat))
{
array_pop($tags);
$k++;
}
array_pop($tags);
break;
}
}
$this->result = array('@attributes' => array());
eval($this->evalCode);
$last = $this->array_reindex($this->result);
return $last;
}
Good morning,
I am currently working with your SDK in a version 7.1 of php and I have found a problem with a variable declaration in the file "simplexml.class.php", in the function "xml_load_file", where $ this-> result = ''; it must be $ this-> result = array ();
Thank you