    /*
     * call-seq:
     *   attribute_at(index)
     *
     * Get the value of attribute at +index+
     */
    static VALUE attribute_at(VALUE self, VALUE index)
    {
      xmlTextReaderPtr reader;
      Data_Get_Struct(self, xmlTextReader, reader);

      if(index == Qnil) return Qnil;
      index = rb_funcall(index, rb_intern("to_i"), 0);

      xmlChar * value = xmlTextReaderGetAttributeNo(
          reader,
          NUM2INT(index)
      );
      if(value == NULL) return Qnil;

      VALUE MAYBE_UNUSED(enc) = rb_iv_get(self, "@encoding");
      VALUE rb_value = NOKOGIRI_STR_NEW2(value,
          RTEST(enc) ? StringValuePtr(enc) : NULL);
      xmlFree(value);
      return rb_value;
    }