src/SimpleDOM.php
public function xpathByAttribute($strXpathQuery, $strIndexAttribute = 'name')
    {

        $arrOut = array();
        $objResult = $this->xpath($strXpathQuery);

        foreach ($objResult as $intIndex => $objNode) {
            $strIndex = (string)$objNode->attributes()->$strIndexAttribute;
            $arrOut[$strIndex] = $objResult[$intIndex];
        }

        return $arrOut;
    }
public function xpathByAttribute($strXpathQuery, $strIndexAttribute = 'name')
    {

        $arrOut = array();
        $objResult = $this->xpath($strXpathQuery);

        foreach ($objResult as $intIndex => $objNode) {
            $strIndex = (string)$objNode->attributes()->$strIndexAttribute;
            $arrOut[$strIndex] = $objResult[$intIndex];
        }

        return $arrOut;
    }
Execute xpath query and index by attribute

@param string $strXpathQuery
@param string $strIndexAttribute
@return static[]