/*
* call-seq:
* get(attribute)
*
* Get the value for +attribute+
*/
static VALUE get(VALUE self, VALUE rattribute)
{
xmlNodePtr node;
xmlChar* value = 0;
VALUE rvalue ;
char* attribute = 0;
char *colon = 0, *attr_name = 0, *prefix = 0;
xmlNsPtr ns;
if (NIL_P(rattribute)) return Qnil;
Data_Get_Struct(self, xmlNode, node);
attribute = strdup(StringValuePtr(rattribute));
colon = strchr(attribute, ':');
if (colon) {
(*colon) = 0 ; /* create two null-terminated strings of the prefix and attribute name */
prefix = attribute ;
attr_name = colon + 1 ;
ns = xmlSearchNs(node->doc, node, (const xmlChar *)(prefix));
if (ns) {
value = xmlGetNsProp(node, (xmlChar*)(attr_name), ns->href);
}
} else {
value = xmlGetNoNsProp(node, (xmlChar*)attribute);
}
free(attribute);
if (!value) return Qnil;
rvalue = NOKOGIRI_STR_NEW2(value);
xmlFree(value);
return rvalue ;
}