public function getDescendant(
        SimpleXMLElement $element,
        array $path
    ) {
        foreach ($path as $childProperties) {
            if (!is_array($childProperties)
                || empty($childProperties)
            ) {
                throw new InvalidArgumentException('Invalid descendant path');
            }

            $name       = array_shift($childProperties);
            $attributes = count($childProperties)
                ? array_shift($childProperties)
                : [];

            $element = $this->getChild($element, $name, $attributes);
        }

        return $element;
    }
public function getDescendant(
        SimpleXMLElement $element,
        array $path
    ) {
        foreach ($path as $childProperties) {
            if (!is_array($childProperties)
                || empty($childProperties)
            ) {
                throw new InvalidArgumentException('Invalid descendant path');
            }

            $name       = array_shift($childProperties);
            $attributes = count($childProperties)
                ? array_shift($childProperties)
                : [];

            $element = $this->getChild($element, $name, $attributes);
        }

        return $element;
    }
public function getDescendant ( SimpleXMLElement $ element , array $ path ) { foreach ( $ path as $ childProperties ) { if ( ! is_array ( $ childProperties ) || empty ( $ childProperties ) ) { throw new InvalidArgumentException ( 'Invalid descendant path' ) ; } $ name = array_shift ( $ childProperties ) ; $ attributes = count ( $ childProperties ) ? array_shift ( $ childProperties ) : [ ] ; $ element = $ this -> getChild ( $ element , $ name , $ attributes ) ; } return $ element ; }
Get a descendant, create it when it does not exist.

@param SimpleXMLElement $element
@param array            $path

@return SimpleXMLElement

@throws InvalidArgumentException When the descendant path is invalid.
Get a descendant create it when it does not exist .