namespace Entity;
/**
* @method Repository\User getRepository()
*/
class User
{
// ...
}
$data = <<<XML
<settings>
<one type="gui" subtype="fullscreen">true</one>
<two type="gui" subtype="alphablend">255</two>
</settings>
XML;
function parse_xml($data)
{
$result = [];
$xml = simplexml_load_string($data);
/** @var SimpleXMLElement $node */
foreach ($xml as $key => $node) {
$value = [];
foreach ($node->attributes() as $k => $v) {
$value[$k] = (string) $v;
}
$value['value'] = (string) $node;
$result[$key] = $value;
}
return $result;
}
var_dump(parse_xml($data));
array(2) {
'one' =>
array(3) {
'type' =>
string(3) "gui"
'subtype' =>
string(10) "fullscreen"
'value' =>
string(4) "true"
}
'two' =>
array(3) {
'type' =>
string(3) "gui"
'subtype' =>
string(10) "alphablend"
'value' =>
string(3) "255"
}
}