I wanted to take the fields such as School Type, Name, Location, Details, Degreemjor, Education details, Start and End Date
How can i do this using the foreach loop
I'm an idiot, it didn't click that that was XML. Okay, so your array appears to be an array of schools/institutions from a resume, correct? Just follow the XML hierarchy to reach each node that you care about.
foreach ($nodes as $node) {
echo "Type: " . $node->attributes()['SchoolType'] . "\n";
echo "Name: " . $node->School->SchoolName . "\n";
echo "Location: " . $node->SchoolLocation . "\n";
echo "Degree name: " . $node->Degree->DegreeName . "\n";
// etc
}
Have a look at SimpleXMLElement::attributes
I think you can get the element like
$url = 'http://recruitplushrxmlapidemo.onlineresumeparser.com/hrxml/153Melanie%20R.%20Mather%20Mills.xml';
$sxml = simplexml_load_file($url);
foreach($sxml->StructuredXMLResume->EducationHistory->SchoolOrInstitution as $key => $value){
echo 'SchoolType --> '.$value->attributes()['SchoolType'];
echo "<br />";
echo 'SchoolName --> '.$value->School->SchoolName;
echo "<br />";
echo 'SchoolLocation --> '.$value->SchoolLocation;
echo "<br />";
echo 'DegreeMajor --> '.$value->Degree->DegreeMajor[0];
echo "<br />";
echo 'EducationDetails --> '.$value->Degree->EducationDetails;
echo "<br />";
echo 'StartDate --> '.$value->Degree->DateofAttendance->StartDate[0];
echo "<br />";
echo 'EndDate --> '.$value->Degree->DateofAttendance->EndDate->AnyDate;
echo "<br /><br />";
}