Method: XPather.new

Defined in:
ext/xpather/xpather.c

.new(xmlStr) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'ext/xpather/xpather.c', line 110

VALUE constructor(VALUE self, VALUE xmlStr)
{
  xmlDocPtr doc;
  const char *xmlCStr = StringValueCStr(xmlStr);
  VALUE argv[1];
  VALUE t_data;

  doc = xmlParseMemory(xmlCStr, (int)strlen(xmlCStr));
  if (doc == NULL) {
    fprintf(stderr, "Error: unable to parse xml\n");
    return Qnil;
  }

  t_data = Data_Wrap_Struct(self, 0, xml_free, doc);
  argv[0] = xmlStr;
  rb_obj_call_init(t_data, 1, argv);
  return t_data;
}