I am trying to get DL's DT and DD which is under a class and trying to put those in a foreach. But facing some troubles,
<dl class="c-explain2">
<dt>所在地</dt>
<dd>
大阪府大阪市 北区天満1丁目25番1(地番)
<br>
Here is my codes;
$DOMParser = new \DOMDocument();
$DOMParser->loadHTML($html);
$xpath = new \DOMXPath($DOMParser);
$classname="c-explain2";
$getAllTable = $xpath->query("//dl[contains(@class, '$classname')]//");
foreach($getAllTable as $table){
$allProperties = [];
$table->getElementsByTagName('dt')[0]->nodeValue;
$value = $table->getElementsByTagName('dd')[0]->nodeValue;
$allProperties[] = [
'property' => $property,
'value'=> $value];
}
$insertData[$start_id] = $allProperties;
$MyTable = true;
How to get those dt and dd, After that want to put those in array. Any help? Thank you.