How can i get particular fields in the array using foreach

前端 未结 2 1424
不知归路
不知归路 2020-12-22 08:24

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

2条回答
  •  猫巷女王i
    2020-12-22 09:09

    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 "
    "; echo 'SchoolName --> '.$value->School->SchoolName; echo "
    "; echo 'SchoolLocation --> '.$value->SchoolLocation; echo "
    "; echo 'DegreeMajor --> '.$value->Degree->DegreeMajor[0]; echo "
    "; echo 'EducationDetails --> '.$value->Degree->EducationDetails; echo "
    "; echo 'StartDate --> '.$value->Degree->DateofAttendance->StartDate[0]; echo "
    "; echo 'EndDate --> '.$value->Degree->DateofAttendance->EndDate->AnyDate; echo "

    "; }

提交回复
热议问题