Method: LibXML::XML::Attributes#first

Defined in:
ext/libxml/ruby_xml_attributes.c

#firstXML::Attr

Returns the first attribute.

doc.root.attributes.first

Returns:



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'ext/libxml/ruby_xml_attributes.c', line 246

static VALUE rxml_attributes_first(VALUE self)
{
  xmlNodePtr xnode;
  Data_Get_Struct(self, xmlNode, xnode);

  if (xnode->type == XML_ELEMENT_NODE)
  {
    xmlAttrPtr xattr = xnode->properties;

    if (xattr)
    {
      return rxml_attr_wrap(xattr);
    }
  }
  return Qnil;
}