function xml_depth in Quiz 6.5
Same name and namespace in other branches
- 6.6 includes/moodle/lib/xmlize.php \xml_depth()
@internal You don't need to do anything with this function, it's called by xmlize. It's a recursive function, calling itself as it goes deeper into the xml levels. If you make any improvements, please let me know. @access private
1 call to xml_depth()
- xmlize in includes/
moodle/ lib/ xmlize.php - Create xml formatted output from an array.
File
- includes/
moodle/ lib/ xmlize.php, line 83
Code
function xml_depth($vals, &$i) {
$children = array();
if (isset($vals[$i]['value'])) {
array_push($children, $vals[$i]['value']);
}
while (++$i < count($vals)) {
switch ($vals[$i]['type']) {
case 'open':
if (isset($vals[$i]['tag'])) {
$tagname = $vals[$i]['tag'];
}
else {
$tagname = '';
}
if (isset($children[$tagname])) {
$size = sizeof($children[$tagname]);
}
else {
$size = 0;
}
if (isset($vals[$i]['attributes'])) {
$children[$tagname][$size]['@'] = $vals[$i]["attributes"];
}
$children[$tagname][$size]['#'] = xml_depth($vals, $i);
break;
case 'cdata':
array_push($children, $vals[$i]['value']);
break;
case 'complete':
$tagname = $vals[$i]['tag'];
if (isset($children[$tagname])) {
$size = sizeof($children[$tagname]);
}
else {
$size = 0;
}
if (isset($vals[$i]['value'])) {
$children[$tagname][$size]["#"] = $vals[$i]['value'];
}
else {
$children[$tagname][$size]["#"] = '';
}
if (isset($vals[$i]['attributes'])) {
$children[$tagname][$size]['@'] = $vals[$i]['attributes'];
}
break;
case 'close':
return $children;
break;
}
}
return $children;
}