+ if (tmp_size == 0)
+ {
+ WARNING ("curl_xml plugin: "
+ "relative xpath expression \"%s\" doesn't match any of the nodes. "
+ "Skipping...", xpath->values[j].path);
+ xmlXPathFreeObject (values_node_obj);
+ continue;
+ }
+
+ if (tmp_size > 1)
+ {
+ WARNING ("curl_xml plugin: "
+ "relative xpath expression \"%s\" is expected to return "
+ "only one node. Skipping...", xpath->values[j].path);
+ xmlXPathFreeObject (values_node_obj);
+ continue;
+ }
+
+ /* ignoring the element if other than textnode/attribute*/
+ if (cx_if_not_text_node(values_node->nodeTab[0]))
+ {
+ WARNING ("curl_xml plugin: "
+ "relative xpath expression \"%s\" is expected to return "
+ "only text/attribute node which is not the case. Skipping...",
+ xpath->values[j].path);
+ xmlXPathFreeObject (values_node_obj);
+ continue;
+ }
+
+ vl.values = (value_t *) malloc (sizeof (value_t) * vl.values_len);
+ if (vl.values == NULL)
+ {
+ ERROR ("curl_xml plugin: malloc failed.");
+ xmlXPathFreeObject (base_node_obj);
+ xmlXPathFreeObject (instance_node_obj);
+ xmlXPathFreeObject (values_node_obj);
+ return (-1);
+ }
+
+ node_value = (char *) xmlNodeGetContent(values_node->nodeTab[0]);
+ switch (ds->ds[j].type)
+ {
+ case DS_TYPE_COUNTER:
+ vl.values[j].counter = atoi(node_value);
+ break;
+ case DS_TYPE_DERIVE:
+ vl.values[j].derive = atoi(node_value);
+ break;
+ case DS_TYPE_ABSOLUTE:
+ vl.values[j].absolute = atoi(node_value);
+ break;
+ case DS_TYPE_GAUGE:
+ vl.values[j].absolute = atoi(node_value);
+ }
+
+ if (xpath->instance_prefix != NULL)
+ {
+ if (instance_node != NULL)
+ ssnprintf (vl.type_instance, sizeof (vl.type_instance),"%s-%s",
+ xpath->instance_prefix, (char *) xmlNodeGetContent(instance_node->nodeTab[0]));
+ else
+ sstrncpy (vl.type_instance, xpath->instance_prefix,
+ sizeof (vl.type_instance));
+ }
+ else
+ {
+ /* If instance_prefix and instance_node are NULL , then */
+ /* don't set the type_instance */
+ if (instance_node != NULL)
+ sstrncpy (vl.type_instance, (char *) xmlNodeGetContent(instance_node->nodeTab[0]),
+ sizeof (vl.type_instance));
+ }
+
+ /* free up object */
+ xmlXPathFreeObject (values_node_obj);
+
+ /* We have reached here which means that */
+ /* we have got something to work */
+ status = 0;
+ }
+
+ /* submit the values */
+ if (vl.values)
+ plugin_dispatch_values (&vl);
+
+ sfree(vl.values);
+ if (instance_node_obj != NULL)
+ xmlXPathFreeObject (instance_node_obj);