I am trying to create something for php html dom to work with a element path pattern.
It looks as fallow. I can have different paths where I want to have some text out. like;
$elements = 'h1;span;';
$elements = 'div.test;h2;span';
I tried to create an function to handle these inserts but I am stuck on the part to set 'getElementsByTagName()' in the good order and to receive the value of the last element,
what I have done now;
function convertName($html, $elements) {
$elements = explode(';', $elements);
$dom = new DOMDocument;
$dom->loadHTML($html);
$name = null;
foreach ($elements as $element) :
$name. = getElementsByTagName($element)->item(0)->;
endforeach;
$test = $dom->$name.'nodeValue';
print_r($test); // receive value
}
I hope someone can give me some input or examples.