/* * call-seq: * attribute_nodes * * Get a list of attributes for this Node */ static VALUE attribute_nodes(VALUE self) { xmlTextReaderPtr reader; VALUE attr ; Data_Get_Struct(self, xmlTextReader, reader); attr = rb_ary_new() ; if (! has_attributes(reader)) return attr ; xmlNodePtr ptr = xmlTextReaderExpand(reader); if(ptr == NULL) return Qnil; // FIXME I'm not sure if this is correct..... I don't really like pointing // at this document, but I have to because of the assertions in // the node wrapping code. if(!ptr->doc->_private) { VALUE rb_doc = Data_Wrap_Struct(cNokogiriXmlDocument, 0, 0, ptr->doc); rb_iv_set(rb_doc, "@decorators", Qnil); ptr->doc->_private = (void *)rb_doc; } VALUE enc = rb_iv_get(self, "@encoding"); if(enc != Qnil && NULL == ptr->doc->encoding) { ptr->doc->encoding = calloc((size_t)RSTRING_LEN(enc), sizeof(char)); strncpy( (char *)ptr->doc->encoding, StringValuePtr(enc), (size_t)RSTRING_LEN(enc) ); } Nokogiri_xml_node_properties(ptr, attr); return attr ; }