public function getChild(
        SimpleXMLElement $element,
        $name,
        array $attributes = []
    ) {
        $xpath = $name . $this->getAttributesXpath($attributes);

        $result = $element->xpath($xpath);
        if (empty($result)) {
            $node = $element->addChild($name);
            $this->setAttributes($node, $attributes);
        } else {
            $node = reset($result);
        }

        return $node;
    }
public function getChild(
        SimpleXMLElement $element,
        $name,
        array $attributes = []
    ) {
        $xpath = $name . $this->getAttributesXpath($attributes);

        $result = $element->xpath($xpath);
        if (empty($result)) {
            $node = $element->addChild($name);
            $this->setAttributes($node, $attributes);
        } else {
            $node = reset($result);
        }

        return $node;
    }
public function getChild ( SimpleXMLElement $ element , $ name , array $ attributes = [ ] ) { $ xpath = $ name . $ this -> getAttributesXpath ( $ attributes ) ; $ result = $ element -> xpath ( $ xpath ) ; if ( empty ( $ result ) ) { $ node = $ element -> addChild ( $ name ) ; $ this -> setAttributes ( $ node , $ attributes ) ; } else { $ node = reset ( $ result ) ; } return $ node ; }
Get a child node, create it when it does not exist.

@param SimpleXMLElement $element
@param string           $name
@param array            $attributes

@return SimpleXMLElement
Get a child node create it when it does not exist .