mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Code formatting fixes for Convert::recursiveXMLToArray()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@77324 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
e768d955df
commit
9dd77371a7
@ -230,24 +230,28 @@ class Convert extends Object {
|
|||||||
return self::recursiveXMLToArray($xml);
|
return self::recursiveXMLToArray($xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function recursively run from {@link Convert::xml2array()}
|
||||||
|
* @uses SimpleXMLElement
|
||||||
|
*/
|
||||||
protected static function recursiveXMLToArray($xml) {
|
protected static function recursiveXMLToArray($xml) {
|
||||||
if (get_class($xml) == 'SimpleXMLElement') {
|
if(get_class($xml) == 'SimpleXMLElement') {
|
||||||
$attributes = $xml->attributes();
|
$attributes = $xml->attributes();
|
||||||
foreach($attributes as $k=>$v) {
|
foreach($attributes as $k => $v) {
|
||||||
if ($v) $a[$k] = (string) $v;
|
if($v) $a[$k] = (string) $v;
|
||||||
}
|
}
|
||||||
$x = $xml;
|
$x = $xml;
|
||||||
$xml = get_object_vars($xml);
|
$xml = get_object_vars($xml);
|
||||||
}
|
}
|
||||||
if (is_array($xml)) {
|
if(is_array($xml)) {
|
||||||
if (count($xml) == 0) return (string) $x; // for CDATA
|
if(count($xml) == 0) return (string) $x; // for CDATA
|
||||||
foreach($xml as $key=>$value) {
|
foreach($xml as $key => $value) {
|
||||||
$r[$key] = self::recursiveXMLToArray($value);
|
$r[$key] = self::recursiveXMLToArray($value);
|
||||||
}
|
}
|
||||||
if (isset($a)) $r['@'] = $a; // Attributes
|
if(isset($a)) $r['@'] = $a; // Attributes
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
return (string) $xml;
|
return (string) $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function array2json( $array ) {
|
static function array2json( $array ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user