public static function findTagOrAttribute($tag, $attrs, $subject) {
        $xml = new \XMLReader();
        $xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE);
        // failed to parse => false
        if ($xml->read() === false) {
            return false;
        }

        if (!is_null($attrs) && !is_array($attrs)) {
            $attrs = [$attrs => null];
        }

        while ($xml->read()) {
            if (!is_null($tag) && $xml->name == $tag) {
                return true; // tag found
            }
            if (!is_null($attrs)) {
                foreach ($attrs as $attr => $attrValue) {
                    $value = $xml->getAttribute($attr);
                    if (!is_null($value)
                        && (is_null($attrValue) || $value == $attrValue)) {
                        return true;
                    }
                }
            }
        }

        return false;
    }