I would like to create the code to extract all the data from an XML field. I have some knowledge of PHP but I am far from good knowledge.
I have an XML file and I would like to show all the Infos that come from certain fields.
I managed to extract on all the fields which will have only one value per field.
But there is the field "WorkingTimes" which can have 2 values at once. I need to show both of them (when they exist)
I attached a screenshot to help you understand better what I need. Right now, for the other field I use the following code (just an example):
<?php
if(isset($xml->jobPublication)) {
foreach($xml->jobPublication as $job) {
echo "<h3>".$job->jobOpening->location."</h3>";
}
}
?>
This will print the value from the Field Location. It is always 1 value.
So, I would need help for the field "WorkingTimes" which can show 2 values.
Thank you in advance, any help would be appreciated.
Give it a try
<?php
if(isset($xml->jobPublication)) {
foreach($xml->jobPublication as $job) {
echo "<h3>".$job->jobOpening->location."</h3>";
foreach($job->jobOpening->workingTimes->workTime as $wrkTime){
echo "<p>".$wrkTime->name."</p>";
}
}
}
?>