I need to get multiple values from nodes and their attributes using xpath. Some of them not always exist so i need to check before geting value. I know that i can write if statement for each of them to check length, but i wonder if there is a easier way to do it.
im getting data using this example:
$xpath = new DOMXPath($doc); $xpath->query('/list/node/@val')->item(0)->nodeValue; $xpath->query('/list/node/node')->item(0)->nodeValue;