Get an element weight by attribute.
Uses regular expressions to tell if this element looks good or bad.

@param \DOMElement $element
@param string      $attribute

@return int
8857
protected function weightAttribute(\DOMElement $element, $attribute)
    {
        if (!$element->hasAttribute($attribute)) {
            return 0;
        }
        $weight = 0;

        // $attributeValue = trim($element->getAttribute('class')." ".$element->getAttribute('id'));
        $attributeValue = trim($element->getAttribute($attribute));

        if ('' !== $attributeValue) {
            if (preg_match($this->regexps['negative'], $attributeValue)) {
                $weight -= 25;
            }
            if (preg_match($this->regexps['positive'], $attributeValue)) {
                $weight += 25;
            }
            if (preg_match($this->regexps['unlikelyCandidates'], $attributeValue)) {
                $weight -= 5;
            }
            if (preg_match($this->regexps['okMaybeItsACandidate'], $attributeValue)) {
                $weight += 5;
            }
        }

        return $weight;
    }
240724
public function attr($attribute)
    {
        if (!$this->attributes instanceof EntityAttributeContainer) {
            $this->attributes = $this->createEntityAttributeContainer();
        }

        return $this->attributes->attr($attribute);
    }
518909
protected function takeAttributeFromDOM($attribute)
    {
        switch ($attribute->localName) {
            case 'min':
                $this->_min = $attribute->nodeValue;
                break;
            case 'max':
                $this->_max = $attribute->nodeValue;
                break;
            case 'numRaters':
                $this->_numRaters = $attribute->nodeValue;
                break;
            case 'average':
                $this->_average = $attribute->nodeValue;
                break;
            case 'value':
                $this->_value = $attribute->nodeValue;
            default:
                parent::takeAttributeFromDOM($attribute);
        }
    }
1269655
public function getAttribute($attribute)
    {
        //Check this attribute is support
        if (isset($this->input_map[$attribute])) {
            return $this->input_map[$attribute];
        } else {
            throw new AttributeInvalidException('Attribute not supported by this library');
        }
    }
1098291
protected function appendAttributesToElementToSend(\DOMElement $element)
    {
        if ($this->hasAttributes()) {
            foreach ($this->getAttributes() as $attributeName => $attributeValue) {
                $matches = [];
                if (0 === preg_match(sprintf('/(%s|%s):/', self::NS_WSSU_NAME, self::NS_WSSE_NAME), $attributeName, $matches)) {
                    $element->setAttribute($attributeName, $attributeValue);
                } else {
                    $element->setAttributeNS(self::NS_WSSE_NAME === $matches[1] ? self::NS_WSSE : self::NS_WSSU, $attributeName, $attributeValue);
                }
            }
        }

        return $this;
    }
1055805
public function dontSeeElementInDOM($selector, $attributes = [])
    {
        $els = $this->match($this->getBaseElement(), $selector);
        $els = $this->filterByAttributes($els, $attributes);
        $this->assertEmpty($els);
    }
1170332
private function getValue(\DOMElement $node)
    {
        $value = $node->nodeValue;

        if ('boolean' === $type = $node->getAttribute('type')) {
            return 'true' === $value;
        }

        settype($value, $type);

        return $value;
    }
814268
def element_to_int(element, attribute=None):
    
    if attribute is not None:
        return int(element.get(attribute))
    else:
        return int(element.text)
981219
protected function checkAttributeNode(DOMAttr $attribute, Tag $tag)
	{
		// Parse the attribute value for XPath expressions and assess their safety
		foreach (AVTHelper::parse($attribute->value) as $token)
		{
			if ($token[0] === 'expression')
			{
				$this->checkExpression($attribute, $token[1], $tag);
			}
		}
	}
72238
public function element(String $element, String $str = NULL, Array $attributes = []) : String
    {
        return $this->_multiElement($element, $str, $attributes);
    }
482928
protected function getValueFromElement(DOMElement $element)
	{
		return (!$element->attributes->length && $element->childNodes->length === 1 && $element->firstChild->nodeType === XML_TEXT_NODE)
		     ? $element->nodeValue
		     : $this->getElementConfig($element);
	}
520675
protected function takeAttributeFromDOM($attribute)
    {
        switch ($attribute->localName) {
        case 'url':
            $this->_url = $attribute->nodeValue;
            break;
        default:
            parent::takeAttributeFromDOM($attribute);
        }
    }
1145630
public function retriveAttributeType(\DOMElement $element)
    {
        $name = $this->engine->query($element->getNodePath() . '/dia:attribute[@name="type"]/dia:string');
        return $this->cleanString($name->item(0)->nodeValue);
    }
398227
protected function takeAttributeFromDOM($attribute)
    {
        switch ($attribute->localName) {
        case 'type':
            $this->_type = $attribute->nodeValue;
            break;
        case 'lang':
            $this->_lang = $attribute->nodeValue;
            break;
        case 'start':
            $this->_start = $attribute->nodeValue;
            break;
        case 'end':
            $this->_end = $attribute->nodeValue;
            break;
        default:
            parent::takeAttributeFromDOM($attribute);
        }
    }
1143735
private function isElementValueNull(\DOMElement $element): bool
    {
        $namespaceUri = 'http://www.w3.org/2001/XMLSchema-instance';

        if (!$element->hasAttributeNS($namespaceUri, 'nil')) {
            return false;
        }

        return 'true' === $element->getAttributeNS($namespaceUri, 'nil') || '1' === $element->getAttributeNS($namespaceUri, 'nil');
    }
263336
protected function addRelAttribute(DOMElement $element)
	{
		$rel = $element->getAttribute('rel');
		if (preg_match('(\\S$)', $rel))
		{
			$rel .= ' ';
		}
		$rel .= 'noreferrer';

		$element->setAttribute('rel', $rel);
	}
885598
protected static function getProperties(DOMElement $element)
	{
		return (isset(self::$htmlElements[$element->nodeName])) ? self::$htmlElements[$element->nodeName] : self::$htmlElements['span'];
	}