extract node attribute value

@return string, the extracted content
@param DOMNodeList $nodeList
@param string $attributeName
172070
public function extractNodeAttributeVal(DOMNodeList $nodeList, $attributeName)
    {
        return ($nodeList->length)? $nodeList->item(0)->getAttribute($attributeName) : null;
    }
52393
public static function getCustomAttribute( $tag, $attributeName )
    {
        foreach ( $tag->attributes as $attribute )
        {
            if ( $attribute->name === $attributeName
              && $attribute->namespaceURI === 'http://ez.no/namespaces/ezpublish3/custom/' )
            {
                return $attribute->value;
            }
        }
        return null;
    }
286602
protected function getNodeValueByTagName(DOMElement $node, $tagName)
    {
        $results = $node->getElementsByTagName($tagName);
        for ($i = 0; $i < $results->length; $i++) {
            $result = $results->item($i);
            if (!$result->nodeValue) {
                continue;
            }

            return $result->nodeValue;
        }

        return false;
    }
555289
public function extract($xmltext) {
        libxml_disable_entity_loader(true);
        try {
            $xml = new DOMDocument();
            $xml->loadXML($xmltext);
            $array_e    = $xml->getElementsByTagName('Encrypt');
            $array_a    = $xml->getElementsByTagName('ToUserName');
            $encrypt    = $array_e->item(0)->nodeValue;
            $tousername = $array_a->item(0)->nodeValue;
            return array(0, $encrypt, $tousername);
        } catch (Exception $e) {
            print $e . "\n";
            //return array(ErrorCode::$ParseXmlError, null, null);
        }
    }
405866
public static NodeList xpathNodeList(Node document, XPathExpression xpathExpression) throws XPathException, MarshallingException
    {
        return (NodeList) executeXPath(document, xpathExpression, XPathConstants.NODESET);
    }
611570
protected function extractRelationshipAttributes($columnName, array $attributes)
    {
        $attributes = filter_array_keys($attributes, function ($key) use ($columnName) {
            return starts_with($key, $columnName . '.');
        });

        $extractedAttributes = [];

        foreach ($attributes as $key => $value) {
            $key = substr($key, strlen($columnName) + 1);
            $extractedAttributes[$key] = $value;
        }

        return $extractedAttributes;
    }
962993
public NodeList getNodeList(Object node, String expression) {
		return (NodeList) evalXPath(expression, node, XPathConstants.NODESET);
	}
578013
function(node, attributeName) {
			var out = [],
				attList;

			attList = node.getAttribute(attributeName);
			if(attList && attList !== '') {
				if(attList.indexOf(' ') > -1) {
					out = attList.split(' ');
				} else {
					out.push(attList);
				}
			}
			return out;
		}
1307027
public function extract($xmltext)
	{
		try {
			$xml = new DOMDocument();
			$xml->loadXML($xmltext);
			$array_e = $xml->getElementsByTagName('Encrypt');
			$array_a = $xml->getElementsByTagName('ToUserName');
			$encrypt = $array_e->item(0)->nodeValue;
			$tousername = $array_a->item(0)->nodeValue;
			return array(0, $encrypt, $tousername);
		} catch (Exception $e) {
			//print $e . "\n";
			return array(ErrorCode::$ParseXmlError, null, null);
		}
	}
670162
private function createAttributeNode(PropertyMetadata $metadata, string $attributeName): \DOMAttr
    {
        if ($namespace = (string) $metadata->xmlNamespace) {
            $prefix = $this->lookupPrefix($namespace);
            $node = $this->document->createAttributeNS($namespace, $prefix.':'.$attributeName);
        } else {
            $node = $this->document->createAttribute($attributeName);
        }

        return $node;
    }
1148764
public function findXPath(string $xpath): NodeList {
        $results = $this->newNodeList();

        if ($this->isRemoved()) {
            return $results;
        }

        $domxpath = new \DOMXPath($this->document());

        foreach ($this->collection() as $node) {
            $results = $results->merge(
                $node->newNodeList($domxpath->query($xpath, $node))
            );
        }

        return $results;
    }
118961
private NodeList getNodeList(String document, XPathExpression expression) throws Exception
   {
      Document doc = m_documentBuilder.parse(new InputSource(new StringReader(document)));
      return (NodeList) expression.evaluate(doc, XPathConstants.NODESET);
   }
859281
public function getChild( $nodeName )
	{
		for( $i=0; $i<count( $this->children ); $i++ )
			if( $this->children[$i]->getNodeName() == $nodeName )
				return $this->children[$i];
		throw new InvalidArgumentException( 'Child Node with Node Name "'.$nodeName.'" is not existing.' );
	}
892849
public function getChildNodes($nodeName = "", $nodeAttributes = array())
    {
        // init
        $obj = new TagCollection(); // array(); // null;
        $count = 0;

        // action
        foreach ($this->Nodes as $node) {
            if (gettype($node) == 'object'
                && get_class($node) == 'Com\PaulDevelop\Library\Modeling\Xml\Tag'
            ) {
                if ($node->Name == $nodeName) {
                    // if found child node with good name, check attributes as well
                    $allAttributesAreOK = true;
                    foreach ($nodeAttributes as $key => $value) {
                        if ($node[$key]->Value != $value) {
                            $allAttributesAreOK = false;
                            break;
                        }
                    }

                    if ($allAttributesAreOK == true) {
                        $count++;
                        $obj->add($node, $count);
                    }
                }
            }
        }

        // return
        return $obj;
    }
439417
public static function getChildElement(DOMElement $parent, $childName)
    {
        $listElements = $parent->getElementsByTagName($childName);
        if ($listElements->length > 0) {
            for ($i = 0; $i < $listElements->length; $i++) {
                $currentItem = $listElements->item($i);
                if ($parent->isSameNode($currentItem->parentNode)) {
                    return $currentItem;
                }
            }
        }

        return null;
    }
355684
private function _getAttributesByKeyName($keyName="Name")
    {
        $attributes = array();

        $entries = $this->_queryAssertion('/saml:AttributeStatement/saml:Attribute');

        /** @var $entry DOMNode */
        foreach ($entries as $entry) {
            $attributeKeyNode = $entry->attributes->getNamedItem($keyName);

            if ($attributeKeyNode === null) {
                continue;
            }

            $attributeKeyName = $attributeKeyNode->nodeValue;

            if (in_array($attributeKeyName, array_keys($attributes))) {
                throw new OneLogin_Saml2_ValidationError(
                    "Found an Attribute element with duplicated ".$keyName,
                    OneLogin_Saml2_ValidationError::DUPLICATED_ATTRIBUTE_NAME_FOUND
                );
            }

            $attributeValues = array();
            foreach ($entry->childNodes as $childNode) {
                $tagName = ($childNode->prefix ? $childNode->prefix.':' : '') . 'AttributeValue';
                if ($childNode->nodeType == XML_ELEMENT_NODE && $childNode->tagName === $tagName) {
                    $attributeValues[] = $childNode->nodeValue;
                }
            }

            $attributes[$attributeKeyName] = $attributeValues;
        }
        return $attributes;
    }
884958
static function fetchAliasesFromNodeList( $nodeList )
    {
        if ( !is_array( $nodeList ) || count( $nodeList ) < 1 )
            return array();

        $db = eZDB::instance();
        $where = $db->generateSQLINStatement( $nodeList, 'node_id', false, false, 'int' );
        $query = "SELECT node_id, path_identification_string FROM ezcontentobject_tree WHERE $where";
        $pathListArray = $db->arrayQuery( $query );
        return $pathListArray;
    }