, :
(node) (DOM)
function getAttachableNodeByAttributeName(\DOMElement $parent = null, string $elementTagName = null, string $attributeName = null, string $attributeValue = null)
{
$returnNode = null;
$needleDOMNode = $parent->getElementsByTagName($elementTagName);
$length = $needleDOMNode->length;
for ($i = $length; --$i >= 0;) {
$needle = $needleDOMNode->item($i);
if (!$attributeName && !$attributeValue && 1 === $length) return $needle;
elseif ($attributeName && $attributeValue && $needle->getAttribute($attributeName) === $attributeValue) return $needle;
}
return $returnNode;
}
:
$countryNode = getAttachableNodeByAttributeName($countriesNode, 'country', 'iso', 'NL');
DOM node iso, ISO NL, . /.
:
$productNode = getAttachableNodeByAttributeName($products, 'partner-products');
DOM node, (root) node, .
: , , . countries->country[ISO] - countries node .