public function query($xpath, $flags = 0)
    {
        $nodes = $this->getXPath()->query($xpath, $this->getDomElement());
        if (0 === $nodes->length && $flags & self::REQUIRED) {
            throw new MalformedNodeException(sprintf('Required node (%s) not found', $xpath));
        }

        if ($flags & self::SINGLE) {
            if ($nodes->length > 1) {
                throw new MalformedNodeException(
                    sprintf(
                        '%s must not contain more than one %s node',
                        $this->getDomElement()->localName,
                        $xpath
                    )
                );
            } elseif ($nodes->length === 0) {
                return null;
            }

            return $nodes->item(0);
        }

        return $nodes;
    }
public function query($xpath, $flags = 0)
    {
        $nodes = $this->getXPath()->query($xpath, $this->getDomElement());
        if (0 === $nodes->length && $flags & self::REQUIRED) {
            throw new MalformedNodeException(sprintf('Required node (%s) not found', $xpath));
        }

        if ($flags & self::SINGLE) {
            if ($nodes->length > 1) {
                throw new MalformedNodeException(
                    sprintf(
                        '%s must not contain more than one %s node',
                        $this->getDomElement()->localName,
                        $xpath
                    )
                );
            } elseif ($nodes->length === 0) {
                return null;
            }

            return $nodes->item(0);
        }

        return $nodes;
    }
public function query ( $ xpath , $ flags = 0 ) { $ nodes = $ this -> getXPath ( ) -> query ( $ xpath , $ this -> getDomElement ( ) ) ; if ( 0 === $ nodes -> length && $ flags & self :: REQUIRED ) { throw new MalformedNodeException ( sprintf ( 'Required node (%s) not found' , $ xpath ) ) ; } if ( $ flags & self :: SINGLE ) { if ( $ nodes -> length > 1 ) { throw new MalformedNodeException ( sprintf ( '%s must not contain more than one %s node' , $ this -> getDomElement ( ) -> localName , $ xpath ) ) ; } elseif ( $ nodes -> length === 0 ) { return null ; } return $ nodes -> item ( 0 ) ; } return $ nodes ; }
Return child DOM element by name.

@param string $xpath XPath expression.
@param int    $flags Flags, see class constants.

@return \DOMNodeList|\DOMElement|null

@throws \Mekras\Atom\Exception\MalformedNodeException If REQUIRED flag set but nothing found.

@since 1.0
Return child DOM element by name .