Well after looking a bit more I found was I was looking for: https://3v4l.org/XdLFN, if anyone can check if im doing it right will appreciate.
$dom = new \DOMDocument();
@$dom->loadHTML($resultApi);
// Create a DOMXPath instance and locate elements
$xpath = new \DOMXPath($dom);
$items = $xpath->query("//fieldset[@class="relative"]");
$result = [];
foreach ($items as $node) {
$title = $xpath->query('.//following-sibling::h5/button', $node)->item(0)->nodeValue;
$div = $xpath->query('.//following-sibling::select', $node);
$result[$title]= 0;
if($div->length){
foreach ($div as $option) {
$children = $option->childNodes;
$countOp = 1;
foreach ($children as $child) {
if($child->nodeName === 'option' && $child->nodeValue !== '-'){
$result[$title]= $countOp++;
}
}
}
}
}
print_r($result);