public function getLabel()
    {
        $xpath = new \DOMXPath($this->node->ownerDocument);

        if ($this->node->hasAttribute('id')) {
            $labels = $xpath->query(sprintf('descendant::label[@for="%s"]', $this->node->getAttribute('id')));
            if ($labels->length > 0) {
                return $labels->item(0);
            }
        }

        $labels = $xpath->query('ancestor::label[1]', $this->node);
        if ($labels->length > 0) {
            return $labels->item(0);
        }
    }
public function getLabel()
    {
        $xpath = new \DOMXPath($this->node->ownerDocument);

        if ($this->node->hasAttribute('id')) {
            $labels = $xpath->query(sprintf('descendant::label[@for="%s"]', $this->node->getAttribute('id')));
            if ($labels->length > 0) {
                return $labels->item(0);
            }
        }

        $labels = $xpath->query('ancestor::label[1]', $this->node);
        if ($labels->length > 0) {
            return $labels->item(0);
        }
    }
public function getLabel ( ) { $ xpath = new \ DOMXPath ( $ this -> node -> ownerDocument ) ; if ( $ this -> node -> hasAttribute ( 'id' ) ) { $ labels = $ xpath -> query ( sprintf ( 'descendant::label[@for="%s"]' , $ this -> node -> getAttribute ( 'id' ) ) ) ; if ( $ labels -> length > 0 ) { return $ labels -> item ( 0 ) ; } } $ labels = $ xpath -> query ( 'ancestor::label[1]' , $ this -> node ) ; if ( $ labels -> length > 0 ) { return $ labels -> item ( 0 ) ; } }
Returns the label tag associated to the field or null if none.

@return \DOMElement|null
Returns the label tag associated to the field or null if none .