Is there any more elegant way to escape SimpleXML attributes to an array?
$result = $xml->xpath( $xpath );
$element = $result[ 0 ];
$attributes = (array)
I think you will have to loop through. You can get it into array once you read xml.
$value) {
if (is_object($value) || is_array($value)) {
$value = objectsIntoArray($value, $arrSkipIndices); // recursive call
}
if (in_array($index, $arrSkipIndices)) {
continue;
}
$arrData[$index] = $value;
}
}
return $arrData;
}
$xmlStr = file_get_contents($xml_file);
$xmlObj = simplexml_load_string($xmlStr);
$arrXml = objectsIntoArray($xmlObj);
foreach($arrXml as $attr)
foreach($attr as $key->$val){
if($key == '@attributes') ....
}