/* * call-seq: * namespace_scopes() * * returns namespaces in scope for self -- those defined on self element * directly or any ancestor node -- as an array of Namespace objects. Default * namespaces ("xmlns=" style) for self are included in this array; Default * namespaces for ancestors, however, are not. See also #namespaces */ static VALUE namespace_scopes(VALUE self) { xmlNodePtr node ; VALUE list; xmlNsPtr *ns_list; int j; Data_Get_Struct(self, xmlNode, node); list = rb_ary_new(); ns_list = xmlGetNsList(node->doc, node); if(!ns_list) return list; for (j = 0 ; ns_list[j] != NULL ; ++j) { rb_ary_push(list, Nokogiri_wrap_xml_namespace(node->doc, ns_list[j])); } xmlFree(ns_list); return list; }