[Solar-talk] Sungrazr_Xml_Simple_Element::toArray()
Rodrigo Moraes
rodrigo.moraes at gmail.com
Wed May 2 23:18:20 PDT 2007
Anybody else here using Sungrazr_Xml_Simple? It's nice. However I've
noticed that Sungrazr_Xml_Simple_Element::toArray() doesn't include
attributes from the top nodes in the conversion. So in the example...
<nodes>
<node attr="abcd">
<node attr="efgh"></node>
</node>
</nodes>
...the result won't include the attribute which value is "abcd". But
there's an easy fix. Break the conditional that checks if attributes
are empty. From:
if (!empty($atts) && is_string($child)) {
$child = array($child);
foreach ($atts as $ak => $av) {
$child[$ak] = $av;
}
}
...to:
if (!empty($atts)) {
if(is_string($child)) {
$child = array($child);
}
foreach ($atts as $ak => $av) {
$child[$ak] = $av;
}
}
Then the array will be complete. Please let me know if this is ok.
rodrigo
More information about the solar-talk
mailing list