How to get sum value of sub-child element in xml file

I need to get the sum total of a sub-child element from mxl file My structure of xml file is as follow


I tried following approach but get Total =0

$xml = simplexml_load_file($target_url);
foreach($xml->ac as $data)
    $total += $data;
echo 'Total is: ' . $total;
1 Like

Got answer from

Perhaps you could give the link to the answer rather than to the guy who answered it @johan?