soap-xml.c

Go to the documentation of this file.
00001 /******************************************************************
00002 *  $Id: soap-xml.c,v 1.13 2006/11/26 20:13:05 m0gg Exp $
00003 *
00004 * CSOAP Project:  A SOAP client/server library in C
00005 * Copyright (C) 2003  Ferhat Ayaz
00006 *
00007 * This library is free software; you can redistribute it and/or
00008 * modify it under the terms of the GNU Library General Public
00009 * License as published by the Free Software Foundation; either
00010 * version 2 of the License, or (at your option) any later version.
00011 *
00012 * This library is distributed in the hope that it will be useful,
00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 * Library General Public License for more details.
00016 *
00017 * You should have received a copy of the GNU Library General Public
00018 * License along with this library; if not, write to the
00019 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020 * Boston, MA  02111-1307, USA.
00021 * 
00022 * Email: ayaz@jprogrammer.net
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     /* no result */
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 }

Generated on Thu Jan 25 23:36:03 2007 for csoap by  doxygen 1.4.6