- temp0 = xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
- if (temp0 == NULL) {
- rrd_set_error("get_string_from_node: xmlNodeListGetString failed.");
- return (-1);
+/* skip all but tags. complain if we do not get the right tag */
+/* dept -1 causes depth to be ignored */
+static xmlChar* get_xml_element (
+ xmlTextReaderPtr reader
+ )
+{
+ while(xmlTextReaderRead(reader)){
+ int type;
+ xmlChar *name;
+ type = xmlTextReaderNodeType(reader);
+ if (type == XML_READER_TYPE_TEXT){
+ xmlChar *value;
+ value = xmlTextReaderValue(reader);
+ rrd_set_error("line %d: expected element but found text '%s'",
+ xmlTextReaderGetParserLineNumber(reader),value);
+ xmlFree(value);
+ return NULL;
+ }
+ /* skip all other non-elements */
+ if (type != XML_READER_TYPE_ELEMENT && type != XML_READER_TYPE_END_ELEMENT)
+ continue;
+
+ name = xmlTextReaderName(reader);
+ if (type == XML_READER_TYPE_END_ELEMENT){
+ xmlChar *temp;
+ xmlChar *temp2;
+ temp = (xmlChar*)sprintf_alloc("/%s",name);
+ temp2 = xmlStrdup(temp);
+ free(temp);
+ xmlFree(name);
+ return temp2;
+ }
+ /* all seems well, return the happy news */
+ return name;