00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027
00028 #include <libxml/tree.h>
00029 #include <libxml/xpath.h>
00030 #include <libxml/xpathInternals.h>
00031
00032 #include <nanohttp/nanohttp-logging.h>
00033
00034 #include "soap-xml.h"
00035
00036 xmlNodePtr
00037 soap_xml_get_children(xmlNodePtr node)
00038 {
00039 xmlNodePtr child;
00040
00041 if (node == NULL)
00042 {
00043 log_error1("Invalid node (null)");
00044 return NULL;
00045 }
00046
00047 for (child = node->children; child; child=child->next)
00048 {
00049 if (child->type == XML_ELEMENT_NODE)
00050 return child;
00051 }
00052
00053 return NULL;
00054 }
00055
00056 xmlNodePtr
00057 soap_xml_get_next(xmlNodePtr param)
00058 {
00059
00060 if (param == NULL)
00061 {
00062 log_error1("Invalid node (null)");
00063 return NULL;
00064 }
00065
00066 xmlNodePtr node = param->next;
00067
00068 while (node != NULL)
00069 {
00070 if (node->type != XML_ELEMENT_NODE)
00071 node = node->next;
00072 else
00073 break;
00074 }
00075
00076 return node;
00077 }
00078
00079 xmlXPathObjectPtr
00080 soap_xpath_eval(xmlDocPtr doc, const char *xpath)
00081 {
00082 xmlXPathContextPtr context;
00083 xmlXPathObjectPtr result;
00084
00085 context = xmlXPathNewContext(doc);
00086 result = xmlXPathEvalExpression(BAD_CAST xpath, context);
00087 if (xmlXPathNodeSetIsEmpty(result->nodesetval))
00088 {
00089
00090 return NULL;
00091 }
00092
00093 xmlXPathFreeContext(context);
00094 return result;
00095 }
00096
00097 char *
00098 soap_xml_get_text(xmlNodePtr node)
00099 {
00100 return (char *) xmlNodeListGetString(node->doc, node->xmlChildrenNode, 1);
00101 }