I'm trying to edit/delete/assign to some variables specific elements at a node within my XML document but i'm not getting anywhere. When i do a print_r i could get an array output of that specific elements but when i assign it to a variable and 'test' echo, nothing comes out.
My php are as follow:
if (file_exists('someXML.xml')) {
$xml = simplexml_load_file('someXML.xml');
//temp fixed value just to test code
$numRecords = 1;
$xPath = $xml->xpath("/root/sirah[id = '$numRecords']");
foreach($xPath as $dPath){
echo $dPath.'</ br>';
}
print_r($xPath);
} else {
exit('Failed to open someXML.xml.');
}
echo $dPath.'</ br>';
doesn't have any output while print_r($xPath);
outputs:
Array ( [0] => SimpleXMLElement Object ( [comment] => SimpleXMLElement Object ( ) [id] => 1 [dateGreg] => 20-04-586 [dateAnum] => 12-05-1436 [dateAtxt] => 12 Rabiul Awal 1436 [titleEng] => English Title [titleMal] => Tajuk dalam Bahasa Melayu [descEng] => Detailed description of event mentioned in title. This just a sample entry to serve as a guideline... [descMal] => Keterangan terperinci tentang tajuk yang yrtyrta di atas. Ini hanya contoh untuk dijadikan hanya sebagai sandaran... [lat] => 20.34287 [long] => 1.9476254 ) )
What could be the issue?