您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xmlXPathEval函数代码示例

51自学网 2021-06-03 11:47:37
  C++
这篇教程C++ xmlXPathEval函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中xmlXPathEval函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlXPathEval函数的具体用法?C++ xmlXPathEval怎么用?C++ xmlXPathEval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了xmlXPathEval函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: xslDbgShellCat

intxslDbgShellCat(xsltTransformContextPtr styleCtxt, xmlShellCtxtPtr ctxt,               xmlChar * arg){    xmlXPathObjectPtr list;    int result = 0;    static const char * QUIET_STR = "-q";    bool silenceCtxtErrors = false;    if ((arg == NULL) || (xmlStrLen(arg) == 0))        arg = (xmlChar *) ".";    /* Do we quietly ingore style context errors */    if (strncasecmp((char*)arg, QUIET_STR, strlen(QUIET_STR))== 0){      silenceCtxtErrors = true;	      arg = arg + strlen(QUIET_STR);      while (isspace(*arg)){	arg++;      }    }    if (!styleCtxt || !ctxt || !ctxt->node) {	if (!(!xsldbgReachedFirstTemplate && silenceCtxtErrors))         xsldbgGenericErrorFunc(i18n("Warning: Unable to print expression. No stylesheet was properly loaded./n"));        return 0;    }    if ((arg == NULL) || (xmlStrLen(arg) == 0))        arg = (xmlChar *) ".";    ctxt->pctxt->node = ctxt->node;    if (!styleCtxt) {        list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);    } else {        xmlNodePtr savenode = styleCtxt->xpathCtxt->node;        ctxt->pctxt->node = ctxt->node;        styleCtxt->xpathCtxt->node = ctxt->node;        if (!xmlXPathNsLookup(styleCtxt->xpathCtxt, (xmlChar *) "xsl"))            xmlXPathRegisterNs(styleCtxt->xpathCtxt, (xmlChar *) "xsl",                               XSLT_NAMESPACE);        list = xmlXPathEval((xmlChar *) arg, styleCtxt->xpathCtxt);        styleCtxt->xpathCtxt->node = savenode;    }    if (list != NULL) {        result = printXPathObject(list, arg);        xmlXPathFreeObject(list);    } else {        xsldbgGenericErrorFunc(i18n("Error: XPath %1 results in an empty Node Set./n").arg(xsldbgText(arg)));    }    ctxt->pctxt->node = NULL;    return result;}
开发者ID:serghei,项目名称:kde3-kdewebdev,代码行数:53,


示例2: config_get_value

const char * config_get_value(const char * _xpath) {    xmlXPathObjectPtr xmlobject = NULL;    const xmlChar * xpath = BAD_CAST(_xpath);    const xmlChar * value = NULL;            /* Rquete XPath*/    xmlobject = xmlXPathEval(xpath, config->context);    if (!xmlobject)        return NULL;        if (xmlobject->type == XPATH_NODESET) {         if (xmlobject->nodesetval) {             /* nodeNr = nb nodes in struct nodesetval */             if (xmlobject->nodesetval->nodeNr > 0) {                xmlNodePtr n;		                n = xmlobject->nodesetval->nodeTab[0];                if ((n->type == XML_TEXT_NODE) ||                     (n->type == XML_CDATA_SECTION_NODE))                    value = n->content;            }        }    }        xmlXPathFreeObject(xmlobject);        return (char *)value;}
开发者ID:frs69wq,项目名称:Simbatch,代码行数:30,


示例3: result

  XPathContext::NodeSet_t XPathContext::find_nodes(const std::string& xpath, const Node* context)  {	if (context != NULL)	{	   m_cobj->node = *const_cast<Node*>(context);	}	else	{	   m_cobj->node = NULL;	}    boost::shared_ptr<xmlXPathObject> result(      xmlXPathEval(reinterpret_cast<const xmlChar*>(xpath.c_str()), m_cobj),      xmlXPathFreeObject);    if (result->type != XPATH_NODESET || result->nodesetval == NULL)    {      return NodeSet_t();    }    NodeSet_t result_nodes;    result_nodes.reserve(result->nodesetval->nodeNr);    for (int i = 0; i < result->nodesetval->nodeNr; ++i)    {      result_nodes.push_back(reinterpret_cast<Node*>(result->nodesetval->nodeTab[i]->_private));    }    return result_nodes;  }
开发者ID:FlavioFalcao,项目名称:libxmlmm,代码行数:29,


示例4: S_xpath_expr

   /// Return the text result (if any) of the xpath expression   TIXML_STRING S_xpath_expr (const xmlDoc * Dp_ptr, const char * cp_xpath_expr)   {      xmlXPathObjectPtr XPOp_ptr;      xmlXPathContextPtr XPCp_ptr;      const xmlChar * Cp_ptr;      TIXML_STRING S_out;         S_out = "";      if (Dp_ptr)      {         XPCp_ptr = xmlXPathNewContext ((xmlDoc *) Dp_ptr);         if (XPCp_ptr)         {            // Evaluate             XPOp_ptr = xmlXPathEval ((const xmlChar *) cp_xpath_expr, XPCp_ptr);            if (XPOp_ptr)            {               Cp_ptr = xmlXPathCastToString (XPOp_ptr);               if (Cp_ptr)                  S_out = (const char *) Cp_ptr;               xmlXPathFreeObject (XPOp_ptr);            }         }         if (XPCp_ptr)            xmlXPathFreeContext (XPCp_ptr);      }      return S_out;   }
开发者ID:deNULL,项目名称:seman,代码行数:30,


示例5: virXPathNode

/** * virXPathNode: * @xpath: the XPath string to evaluate * @ctxt: an XPath context * * Convenience function to evaluate an XPath node set and returning * only one node, the first one in the set if any * * Returns a pointer to the node or NULL if the evaluation failed. */xmlNodePtrvirXPathNode(const char *xpath,             xmlXPathContextPtr ctxt){    xmlXPathObjectPtr obj;    xmlNodePtr relnode;    xmlNodePtr ret;    if ((ctxt == NULL) || (xpath == NULL)) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       "%s", _("Invalid parameter to virXPathNode()"));        return NULL;    }    relnode = ctxt->node;    obj = xmlXPathEval(BAD_CAST xpath, ctxt);    ctxt->node = relnode;    if ((obj == NULL) || (obj->type != XPATH_NODESET) ||        (obj->nodesetval == NULL) || (obj->nodesetval->nodeNr <= 0) ||        (obj->nodesetval->nodeTab == NULL)) {        xmlXPathFreeObject(obj);        return NULL;    }    ret = obj->nodesetval->nodeTab[0];    xmlXPathFreeObject(obj);    return ret;}
开发者ID:hzguanqiang,项目名称:libvirt,代码行数:37,


示例6: virXPathNumber

/** * virXPathNumber: * @xpath: the XPath string to evaluate * @ctxt: an XPath context * @value: the returned double value * * Convenience function to evaluate an XPath number * * Returns 0 in case of success in which case @value is set, *         or -1 if the evaluation failed. */intvirXPathNumber(const char *xpath,               xmlXPathContextPtr ctxt,               double *value){    xmlXPathObjectPtr obj;    xmlNodePtr relnode;    if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       "%s", _("Invalid parameter to virXPathNumber()"));        return -1;    }    relnode = ctxt->node;    obj = xmlXPathEval(BAD_CAST xpath, ctxt);    ctxt->node = relnode;    if ((obj == NULL) || (obj->type != XPATH_NUMBER) ||        (isnan(obj->floatval))) {        xmlXPathFreeObject(obj);        return -1;    }    *value = obj->floatval;    xmlXPathFreeObject(obj);    return 0;}
开发者ID:hzguanqiang,项目名称:libvirt,代码行数:37,


示例7: makeCloneXML

static xmlChar *makeCloneXML(const char *origxml, const char *newname){    xmlDocPtr doc = NULL;    xmlXPathContextPtr ctxt = NULL;    xmlXPathObjectPtr obj = NULL;    xmlChar *newxml = NULL;    int size;    doc = virXMLParseStringCtxt(origxml, _("(volume_definition)"), &ctxt);    if (!doc)        goto cleanup;    obj = xmlXPathEval(BAD_CAST "/volume/name", ctxt);    if (obj == NULL || obj->nodesetval == NULL ||        obj->nodesetval->nodeTab == NULL)        goto cleanup;    xmlNodeSetContent(obj->nodesetval->nodeTab[0], (const xmlChar *)newname);    xmlDocDumpMemory(doc, &newxml, &size);cleanup:    xmlXPathFreeObject(obj);    xmlXPathFreeContext(ctxt);    xmlFreeDoc(doc);    return newxml;}
开发者ID:pdf,项目名称:libvirt,代码行数:28,


示例8: exsltDynEvaluateFunction

static voidexsltDynEvaluateFunction(xmlXPathParserContextPtr ctxt, int nargs) {	xmlChar *str = NULL;	xmlXPathObjectPtr ret = NULL;	if (ctxt == NULL)		return;	if (nargs != 1) {		xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);        xsltGenericError(xsltGenericErrorContext,			"dyn:evalute() : invalid number of args %d/n", nargs);		ctxt->error = XPATH_INVALID_ARITY;		return;	}	str = xmlXPathPopString(ctxt);		if (!str||!xmlStrlen(str)) {		if (str) xmlFree(str);		valuePush(ctxt,xmlXPathNewNodeSet(NULL));		return;	}	ret = xmlXPathEval(str,ctxt->context);	if (ret)		valuePush(ctxt,ret); 	else {		xsltGenericError(xsltGenericErrorContext,			"dyn:evaluate() : unable to evaluate expression '%s'/n",str);		valuePush(ctxt,xmlXPathNewNodeSet(NULL));	}		xmlFree(str);	return;}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:32,


示例9: seed_xml_xpath_eval

static SeedValueseed_xml_xpath_eval (SeedContext ctx,		     SeedObject function,		     SeedObject this_object,		     gsize argument_count,		     const SeedValue arguments[],		     SeedException * exception){  xmlXPathObjectPtr xpath_obj;  xmlXPathContextPtr xpath_ctx;  guchar *xpath;  if (argument_count != 1)    {      seed_make_exception (ctx, exception,			   "ArgumentError",			   "xpathEval expected 1 argument, got %zd",			   argument_count);      return seed_make_null (ctx);    }  xpath_ctx = XML_XPATH_PRIV (this_object);  xpath = (guchar *)seed_value_to_string (ctx, arguments[0], exception);  xpath_obj = xmlXPathEval (xpath, xpath_ctx);  g_free (xpath);  return seed_make_object (ctx, xml_xpathobj_class, xpath_obj);}
开发者ID:iRi-E,项目名称:GNOME-Seed,代码行数:28,


示例10: autoconf

/* If the tag ignor_autoconf if set, disable this feature by * setting the variables  * /proc/sys/net/ipv6/conf/all/autoconf * /proc/sys/net/ipv6/conf/all/accept_ra * /proc/sys/net/ipv6/conf/all/accept_ra_defrtr * /proc/sys/net/ipv6/conf/all/accept_ra_pinfo * /proc/sys/net/ipv6/conf/all/accept_redirects * to 0 to avoid the monitoring host to be attacked */void autoconf(){	char *request ="/config_ndpmon/ignor_autoconf/text()";	char  *flag;	xmlXPathObjectPtr xmlobject = xmlXPathEval ((xmlChar*)request, xpctxt);		if( xmlobject != NULL)	{		    flag = (char *)xmlobject->nodesetval->nodeTab[0]->content;	    ignor_autoconf = atoi(flag);        /* Not working for BSD */#ifdef _LINUX_		/** note: it may be a good option to save values, and restore		 * them when exiting		 */		write_proc("/proc/sys/net/ipv6/conf/all/autoconf",flag);		write_proc("/proc/sys/net/ipv6/conf/all/accept_ra",flag);		write_proc("/proc/sys/net/ipv6/conf/all/accept_ra_defrtr",flag);		write_proc("/proc/sys/net/ipv6/conf/all/accept_ra_pinfo",flag);		write_proc("/proc/sys/net/ipv6/conf/all/accept_redirects",flag);	}#endif	xmlXPathFreeObject (xmlobject);	return;}
开发者ID:ayourtch,项目名称:ndpmon-dot1q,代码行数:36,


示例11: xml_config_for_each_obj

int xml_config_for_each_obj(const xml_config_t *config, const char *pattern,							xml_config_cb_t cb, void *arg1, void *arg2){	xmlXPathObject *objs;	xmlNode *node;	int i, ret = 0;	if (!(objs = xmlXPathEval(BAD_CAST pattern, config->xpc))) {		return -1;	}	if (xmlXPathNodeSetIsEmpty(objs->nodesetval) == 0) {		for (i = 0; i < xmlXPathNodeSetGetLength(objs->nodesetval); i++) {			if (!(node = xmlXPathNodeSetItem(objs->nodesetval, i))) {				continue;			}			if ((ret = cb(node, arg1, arg2)) < 0) {				break;			}		}	}	xmlXPathFreeObject(objs);	return ret;}
开发者ID:Qingtao-Cao,项目名称:obix,代码行数:26,


示例12: virXPathLongLong

/** * virXPathULongLong: * @xpath: the XPath string to evaluate * @ctxt: an XPath context * @value: the returned long long value * * Convenience function to evaluate an XPath number * * Returns 0 in case of success in which case @value is set, *         or -1 if the XPath evaluation failed or -2 if the *         value doesn't have a long format. */intvirXPathLongLong(const char *xpath,                 xmlXPathContextPtr ctxt,                 long long *value){    xmlXPathObjectPtr obj;    xmlNodePtr relnode;    int ret = 0;    if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       "%s", _("Invalid parameter to virXPathLongLong()"));        return -1;    }    relnode = ctxt->node;    obj = xmlXPathEval(BAD_CAST xpath, ctxt);    ctxt->node = relnode;    if ((obj != NULL) && (obj->type == XPATH_STRING) &&        (obj->stringval != NULL) && (obj->stringval[0] != 0)) {        if (virStrToLong_ll((char *) obj->stringval, NULL, 10, value) < 0)            ret = -2;    } else if ((obj != NULL) && (obj->type == XPATH_NUMBER) &&               (!(isnan(obj->floatval)))) {        *value = (long long) obj->floatval;        if (*value != obj->floatval) {            ret = -2;        }    } else {        ret = -1;    }    xmlXPathFreeObject(obj);    return ret;}
开发者ID:hzguanqiang,项目名称:libvirt,代码行数:46,


示例13: virXPathString

/** * virXPathString: * @xpath: the XPath string to evaluate * @ctxt: an XPath context * * Convenience function to evaluate an XPath string * * Returns a new string which must be deallocated by the caller or NULL *         if the evaluation failed. */char *virXPathString(const char *xpath,               xmlXPathContextPtr ctxt){    xmlXPathObjectPtr obj;    xmlNodePtr relnode;    char *ret;    if ((ctxt == NULL) || (xpath == NULL)) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       "%s", _("Invalid parameter to virXPathString()"));        return NULL;    }    relnode = ctxt->node;    obj = xmlXPathEval(BAD_CAST xpath, ctxt);    ctxt->node = relnode;    if ((obj == NULL) || (obj->type != XPATH_STRING) ||        (obj->stringval == NULL) || (obj->stringval[0] == 0)) {        xmlXPathFreeObject(obj);        return NULL;    }    ignore_value(VIR_STRDUP(ret, (char *) obj->stringval));    xmlXPathFreeObject(obj);    return ret;}
开发者ID:hzguanqiang,项目名称:libvirt,代码行数:35,


示例14: get_sha1

/* Get sha1file */static void get_sha1(const char *ident){	char *path = NULL;	char xpath[SIZE];	xmlXPathContextPtr xml_context = NULL;	xmlXPathObjectPtr xmlobject;	(void)crv_strncpy(xpath, "/database/file[@id='", sizeof(xpath));	(void)crv_strncat(xpath, ident, sizeof(xpath));	(void)crv_strncat(xpath, "']" , sizeof(xpath));	path = crv_strdup(xpath);	xmlXPathInit();	xml_context = xmlXPathNewContext (xmldoc);	xmlobject = xmlXPathEval (path, xml_context);	crv_free(path);	if ((xmlobject->type == XPATH_NODESET) )  {		int j;		xmlNodePtr node;		for (j = 0; j < xmlobject->nodesetval->nodeNr; j++)		{			node = xmlobject->nodesetval->nodeTab[j];			xmlChar *Sha1 = xmlGetProp(node, "sha1");			sha1 = crv_strdup(Sha1);			xmlFree (Sha1);		}	}	xmlXPathFreeObject (xmlobject);  xmlXPathFreeContext (xml_context);	}
开发者ID:Creuvard,项目名称:Creuvux,代码行数:33,


示例15: virXPathBoolean

/** * virXPathBoolean: * @xpath: the XPath string to evaluate * @ctxt: an XPath context * * Convenience function to evaluate an XPath boolean * * Returns 0 if false, 1 if true, or -1 if the evaluation failed. */intvirXPathBoolean(const char *xpath,                xmlXPathContextPtr ctxt){    xmlXPathObjectPtr obj;    xmlNodePtr relnode;    int ret;    if ((ctxt == NULL) || (xpath == NULL)) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       "%s", _("Invalid parameter to virXPathBoolean()"));        return -1;    }    relnode = ctxt->node;    obj = xmlXPathEval(BAD_CAST xpath, ctxt);    ctxt->node = relnode;    if ((obj == NULL) || (obj->type != XPATH_BOOLEAN) ||        (obj->boolval < 0) || (obj->boolval > 1)) {        xmlXPathFreeObject(obj);        return -1;    }    ret = obj->boolval;    xmlXPathFreeObject(obj);    return ret;}
开发者ID:hzguanqiang,项目名称:libvirt,代码行数:35,


示例16: rxml_xpath_context_find

/* * call-seq: *    context.find("xpath") -> true|false|number|string|XML::XPath::Object * * Executes the provided xpath function.  The result depends on the execution * of the xpath statement.  It may be true, false, a number, a string or  * a node set. */static VALUE rxml_xpath_context_find(VALUE self, VALUE xpath_expr){  xmlXPathContextPtr xctxt;  xmlXPathObjectPtr xobject;  xmlXPathCompExprPtr xcompexpr;  Data_Get_Struct(self, xmlXPathContext, xctxt);  if (TYPE(xpath_expr) == T_STRING)  {    VALUE expression = rb_check_string_type(xpath_expr);    xobject = xmlXPathEval((xmlChar*) StringValueCStr(expression), xctxt);  }  else if (rb_obj_is_kind_of(xpath_expr, cXMLXPathExpression))  {    Data_Get_Struct(xpath_expr, xmlXPathCompExpr, xcompexpr);    xobject = xmlXPathCompiledEval(xcompexpr, xctxt);  }  else  {    rb_raise(rb_eTypeError,        "Argument should be an intance of a String or XPath::Expression");  }  return rxml_xpath_to_value(xctxt, xobject);}
开发者ID:tekwiz,项目名称:libxml-ruby,代码行数:34,


示例17: xpath

/* * query from root * Note: need to be cautious that  the result from xmlXPathEval call is not freed within  this API * it is up to user to call xmlXPathFreeObject to free it */xmlXPathObjectPtr wsNode::xpath(string xpath){	xmlXPathContextPtr ctxt=xmlXPathNewContext(thisNode->doc);	xmlXPathObjectPtr res=xmlXPathEval((xmlChar *)xpath.c_str(),ctxt);	xmlXPathFreeContext(ctxt);	check_xmlXPathObjectPtr(res, xpath);	return res;}
开发者ID:RGLab,项目名称:boost2protobuf,代码行数:13,


示例18: parse_forecast_xml

static voidparse_forecast_xml (GWeatherInfo    *master_info,                    SoupMessageBody *body){    GWeatherInfoPrivate *priv;    xmlDocPtr doc;    xmlXPathContextPtr xpath_ctx;    xmlXPathObjectPtr xpath_result;    int i;    priv = master_info->priv;    doc = xmlParseMemory (body->data, body->length);    if (!doc)	return;    xpath_ctx = xmlXPathNewContext (doc);    xpath_result = xmlXPathEval (XC("/weatherdata/forecast/time"), xpath_ctx);    if (!xpath_result || xpath_result->type != XPATH_NODESET)	goto out;    for (i = 0; i < xpath_result->nodesetval->nodeNr; i++) {	xmlNodePtr node;	GWeatherInfo *info;	node = xpath_result->nodesetval->nodeTab[i];	info = make_info_from_node (master_info, node);	priv->forecast_list = g_slist_append (priv->forecast_list, info);    }    xmlXPathFreeObject (xpath_result);    xpath_result = xmlXPathEval (XC("/weatherdata/credit/link"), xpath_ctx);    if (!xpath_result || xpath_result->type != XPATH_NODESET)	goto out;    priv->forecast_attribution = g_strdup(_("Weather data from the <a href=/"http://openweathermap.org/">Open Weather Map project</a>")); out:    if (xpath_result)	xmlXPathFreeObject (xpath_result);    xmlXPathFreeContext (xpath_ctx);    xmlFreeDoc (doc);}
开发者ID:UIKit0,项目名称:libgweather,代码行数:46,


示例19: parse_countermeasures

/** Parse counter measures configuration. */void parse_countermeasures() {    char        *config_kill_illegitimate_router=NULL,        *config_kill_wrong_prefix=NULL,        *config_propagate_router_params=NULL,        *config_indicate_ndpmon_presence=NULL,        *request;    xmlXPathObjectPtr xmlobject;    request ="/config_ndpmon/countermeasures/kill_illegitimate_router/text()";    xmlobject = xmlXPathEval ((xmlChar*)request, xpctxt);    if (xmlobject->nodesetval!=NULL) {        config_kill_illegitimate_router = (char*)xmlobject->nodesetval->nodeTab[0]->content;    }    xmlXPathFreeObject (xmlobject);    request ="/config_ndpmon/countermeasures/kill_wrong_prefix/text()";    xmlobject = xmlXPathEval ((xmlChar*)request, xpctxt);    if (xmlobject->nodesetval!=NULL) {        config_kill_wrong_prefix = (char*)xmlobject->nodesetval->nodeTab[0]->content;    }    xmlXPathFreeObject (xmlobject);    request ="/config_ndpmon/countermeasures/propagate_router_params/text()";    xmlobject = xmlXPathEval ((xmlChar*)request, xpctxt);    if (xmlobject->nodesetval!=NULL) {        config_propagate_router_params = (char*)xmlobject->nodesetval->nodeTab[0]->content;    }    xmlXPathFreeObject (xmlobject);    request ="/config_ndpmon/countermeasures/indicate_ndpmon_presence/text()";    xmlobject = xmlXPathEval ((xmlChar*)request, xpctxt);    if (xmlobject->nodesetval!=NULL) {        config_indicate_ndpmon_presence = (char*)xmlobject->nodesetval->nodeTab[0]->content;    }    xmlXPathFreeObject (xmlobject);    cm_guard_init_all(        config_kill_illegitimate_router,        config_kill_wrong_prefix,        config_propagate_router_params,        config_indicate_ndpmon_presence    );}
开发者ID:ayourtch,项目名称:ndpmon-dot1q,代码行数:46,


示例20: rxml_xpath_context_find

/* * call-seq: *    context.find("xpath") -> true|false|number|string|XML::XPath::Object * * Executes the provided xpath function.  The result depends on the execution * of the xpath statement.  It may be true, false, a number, a string or  * a node set. */static VALUE rxml_xpath_context_find(VALUE self, VALUE xpath_expr){  xmlXPathContextPtr xctxt;  xmlXPathObjectPtr xobject;  xmlXPathCompExprPtr xcompexpr;  VALUE result;  Data_Get_Struct(self, xmlXPathContext, xctxt);  if (TYPE(xpath_expr) == T_STRING)  {    VALUE expression = rb_check_string_type(xpath_expr);    xobject = xmlXPathEval((xmlChar*) StringValueCStr(expression), xctxt);  }  else if (rb_obj_is_kind_of(xpath_expr, cXMLXPathExpression))  {    Data_Get_Struct(xpath_expr, xmlXPathCompExpr, xcompexpr);    xobject = xmlXPathCompiledEval(xcompexpr, xctxt);  }  else  {    rb_raise(rb_eTypeError,        "Argument should be an intance of a String or XPath::Expression");  }  if (xobject == NULL)  {    /* xmlLastError is different than xctxt->lastError.  Use     xmlLastError since it has the message set while xctxt->lastError     does not. */    xmlErrorPtr xerror = xmlGetLastError();    rxml_raise(xerror);  }  switch (xobject->type)  {  case XPATH_NODESET:    result = rxml_xpath_object_wrap(xctxt->doc, xobject);    break;  case XPATH_BOOLEAN:    result = (xobject->boolval != 0) ? Qtrue : Qfalse;    xmlXPathFreeObject(xobject);    break;  case XPATH_NUMBER:    result = rb_float_new(xobject->floatval);    xmlXPathFreeObject(xobject);    break;  case XPATH_STRING:    result = rb_str_new2((const char*)xobject->stringval);    xmlXPathFreeObject(xobject);    break;  default:    result = Qnil;    xmlXPathFreeObject(xobject);  }  return result;}
开发者ID:BMorearty,项目名称:Webiva,代码行数:65,


示例21: xslDbgShellPrintList

/** * xslDbgShellPrintList:  * @ctxt: The current shell context * @arg: What xpath to display and in UTF-8 * @dir: If 1 print in dir mode?,  *        otherwise ls mode * * Print list of nodes in either ls or dir format * * Returns 1 on success, *         0 otherwise */intxslDbgShellPrintList(xmlShellCtxtPtr ctxt, xmlChar * arg, int dir){    xmlXPathObjectPtr list;    int result = 0;    if (!ctxt || !arg) {#ifdef WITH_XSLDBG_DEBUG_PROCESS        xsltGenericError(xsltGenericErrorContext,                         "Error: NULL arguments provided/n");#endif        return result;    }    if (arg[0] == 0) {        if (dir)            xmlShellDir(ctxt, NULL, ctxt->node, NULL);        else            xmlShellList(ctxt, NULL, ctxt->node, NULL);        result = 1;             /*assume that this worked */    } else {        ctxt->pctxt->node = ctxt->node;        ctxt->pctxt->node = ctxt->node;        if (!xmlXPathNsLookup(ctxt->pctxt, (xmlChar *) "xsl"))            xmlXPathRegisterNs(ctxt->pctxt, (xmlChar *) "xsl",                               XSLT_NAMESPACE);        list = xmlXPathEval(arg, ctxt->pctxt);        if (list != NULL) {            switch (list->type) {                case XPATH_NODESET:{                        int indx;                        for (indx = 0;                             indx < list->nodesetval->nodeNr; indx++) {                            if (dir)                                xmlShellList(ctxt, NULL,                                             list->nodesetval->                                             nodeTab[indx], NULL);                            else                                xmlShellList(ctxt, NULL,                                             list->nodesetval->                                             nodeTab[indx], NULL);                        }                        result = 1;                        break;                    }                default:                    xmlShellPrintXPathError(list->type, (char *) arg);            }            xmlXPathFreeObject(list);        } else {            xsldbgGenericErrorFunc(i18n("Error: XPath %1 results in an empty Node Set./n").arg(xsldbgText(arg)));        }        ctxt->pctxt->node = NULL;    }    return result;}
开发者ID:serghei,项目名称:kde3-kdewebdev,代码行数:69,


示例22: get_mail

/*Admin mail from the config file to send warnings*/void get_mail(){	char* request ="/config_ndpmon/admin_mail/text()";	xmlXPathObjectPtr xmlobject = xmlXPathEval ((xmlChar*)request, xpctxt);	strncpy(admin_mail,(char*)xmlobject->nodesetval->nodeTab[0]->content, ADMIN_MAIL_SIZE);	xmlXPathFreeObject (xmlobject);	return;}
开发者ID:ayourtch,项目名称:ndpmon-dot1q,代码行数:12,


示例23: get_use_reverse_hostlookups

/* Should we do reverse DNS lookups on an action that is logged? */void get_use_reverse_hostlookups(){	char* request ="/config_ndpmon/use_reverse_hostlookups/text()";	xmlXPathObjectPtr xmlobject = xmlXPathEval ((xmlChar*)request, xpctxt);	if ((xmlobject->nodesetval==NULL) || (strcmp("1", (char*)xmlobject->nodesetval->nodeTab[0]->content)!=0)) use_reverse_hostlookups=0;	else use_reverse_hostlookups=1;	xmlXPathFreeObject (xmlobject);	return;}
开发者ID:ayourtch,项目名称:ndpmon-dot1q,代码行数:12,


示例24: image_add

static bool image_add(GHashTable *images, xmlDocPtr args,        xmlNodePtr image_args, GError **err){    struct vmnetfs_image *img;    xmlXPathContextPtr ctx;    xmlXPathObjectPtr obj;    xmlChar *content;    int i;    ctx = make_xpath_context(args);    ctx->node = image_args;    img = g_slice_new0(struct vmnetfs_image);    img->url = xpath_get_str(ctx, "v:origin/v:url/text()");    img->username = xpath_get_str(ctx,            "v:origin/v:credentials/v:username/text()");    img->password = xpath_get_str(ctx,            "v:origin/v:credentials/v:password/text()");    img->read_base = xpath_get_str(ctx, "v:cache/v:path/text()");    img->fetch_offset = xpath_get_uint(ctx, "v:origin/v:offset/text()");    img->initial_size = xpath_get_uint(ctx, "v:size/text()");    img->chunk_size = xpath_get_uint(ctx, "v:cache/v:chunk-size/text()");    img->etag = xpath_get_str(ctx, "v:origin/v:validators/v:etag/text()");    img->last_modified = xpath_get_uint(ctx,            "v:origin/v:validators/v:last-modified/text()");    obj = xmlXPathEval(BAD_CAST "v:origin/v:cookies/v:cookie/text()", ctx);    for (i = 0; obj && obj->nodesetval && i < obj->nodesetval->nodeNr; i++) {        content = xmlNodeGetContent(obj->nodesetval->nodeTab[i]);        img->cookies = g_list_prepend(img->cookies,                g_strdup((const char *) content));        xmlFree(content);    }    xmlXPathFreeObject(obj);    img->io_stream = _vmnetfs_stream_group_new(NULL, NULL);    img->bytes_read = _vmnetfs_stat_new();    img->bytes_written = _vmnetfs_stat_new();    img->chunk_fetches = _vmnetfs_stat_new();    img->chunk_dirties = _vmnetfs_stat_new();    img->io_errors = _vmnetfs_stat_new();    if (!_vmnetfs_io_init(img, err)) {        _image_free(img);        xmlXPathFreeContext(ctx);        return false;    }    g_hash_table_insert(images, xpath_get_str(ctx, "v:name/text()"), img);    xmlXPathFreeContext(ctx);    return true;}
开发者ID:venkey-ariv,项目名称:vmnetx,代码行数:52,


示例25: xpath_censor

static void xpath_censor(xmlXPathContextPtr ctx, const char *xpath){    xmlXPathObjectPtr result;    int i;    result = xmlXPathEval(BAD_CAST xpath, ctx);    if (result && result->nodesetval) {        for (i = 0; i < result->nodesetval->nodeNr; i++) {            xmlNodeSetContent(result->nodesetval->nodeTab[i],                    (const xmlChar *) "XXXXX");        }    }    xmlXPathFreeObject(result);}
开发者ID:cmusatyalab,项目名称:isr-next,代码行数:14,


示例26: virXPathNodeSet

/** * virXPathNodeSet: * @xpath: the XPath string to evaluate * @ctxt: an XPath context * @list: the returned list of nodes (or NULL if only count matters) * * Convenience function to evaluate an XPath node set * * Returns the number of nodes found in which case @list is set (and *         must be freed) or -1 if the evaluation failed. */intvirXPathNodeSet(const char *xpath,                xmlXPathContextPtr ctxt,                xmlNodePtr **list){    xmlXPathObjectPtr obj;    xmlNodePtr relnode;    int ret;    if ((ctxt == NULL) || (xpath == NULL)) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       "%s", _("Invalid parameter to virXPathNodeSet()"));        return -1;    }    if (list != NULL)        *list = NULL;    relnode = ctxt->node;    obj = xmlXPathEval(BAD_CAST xpath, ctxt);    ctxt->node = relnode;    if (obj == NULL)        return 0;    if (obj->type != XPATH_NODESET) {        virReportError(VIR_ERR_INTERNAL_ERROR,                       _("Incorrect xpath '%s'"), xpath);        xmlXPathFreeObject(obj);        return -1;    }    if ((obj->nodesetval == NULL)  || (obj->nodesetval->nodeNr < 0)) {        xmlXPathFreeObject(obj);        return 0;    }    ret = obj->nodesetval->nodeNr;    if (list != NULL && ret) {        if (VIR_ALLOC_N(*list, ret) < 0) {            virReportOOMError();            ret = -1;        } else {            memcpy(*list, obj->nodesetval->nodeTab,                   ret * sizeof(xmlNodePtr));        }    }    xmlXPathFreeObject(obj);    return ret;}
开发者ID:emaste,项目名称:libvirt,代码行数:60,


示例27: get_server_info

/* Get Info server */static void get_server_info(const char *ident){	char *path = NULL;	char xpath[SIZE];	xmlXPathContextPtr xml_context = NULL;	xmlXPathObjectPtr xmlobject;	long lval;	char *ep;	(void)crv_strncpy(xpath, "/database/file[@id='", sizeof(xpath));	(void)crv_strncat(xpath, ident, sizeof(xpath));	(void)crv_strncat(xpath, "']/server" , sizeof(xpath));	path = crv_strdup(xpath);	xmlXPathInit();	xml_context = xmlXPathNewContext (xmldoc);	xmlobject = xmlXPathEval (path, xml_context);	crv_free(path);	if ((xmlobject->type == XPATH_NODESET) )  {		int j;		xmlNodePtr node;		for (j = 0; j < xmlobject->nodesetval->nodeNr; j++)		{			node = xmlobject->nodesetval->nodeTab[j];			xmlChar *Host = xmlGetProp(node, "host");			if (Host != NULL) {				server = crv_strdup(Host);			}			xmlChar *Port = xmlGetProp(node, "port");			if (Port != NULL) {				lval = strtol(Port, &ep, 10);				if (Port[0] == '/0' || *ep != '/0') {					fprintf(stderr, "%s%s", Port, " is not a number");					return;				}				port = lval;			}			xmlFree (Host);			xmlFree (Port);		}	}	xmlXPathFreeObject (xmlobject);  xmlXPathFreeContext (xml_context);}
开发者ID:Creuvard,项目名称:Creuvux,代码行数:48,


示例28: evaluateXPathExpression

/** * Evaluates an XPath expression on the passed-in context. * * @param pContext Pointer to the context. * @param pczExpression The XPath expression to evaluate * * @return xmlNodeSetPtr pointing to the resulting node set, must be *         freed by the caller. */static xmlNodeSetPtrevaluateXPathExpression(xmlXPathContextPtr pContext, const char * pczExpression){  xmlXPathObjectPtr pObject = xmlXPathEval(CONSTXMLCHAR_P(pczExpression),                                            pContext);  if (!pObject || !pObject->nodesetval)    {      return NULL;    }  xmlNodeSetPtr pNodeSet = pObject->nodesetval;  xmlXPathFreeNodeSetList(pObject);  return pNodeSet;}
开发者ID:TKr,项目名称:lxde-lxpanel,代码行数:26,


示例29: inoreader_source_xpath_foreach_match

/** * This is identical to xpath_foreach_match, except that it takes the context * as parameter. */static voidinoreader_source_xpath_foreach_match (const gchar* expr, xmlXPathContextPtr xpathCtxt, xpathMatchFunc func, gpointer user_data) {	xmlXPathObjectPtr xpathObj = NULL;	xpathObj = xmlXPathEval ((xmlChar*)expr, xpathCtxt);		if (xpathObj && xpathObj->nodesetval && xpathObj->nodesetval->nodeMax) {		int	i;		for (i = 0; i < xpathObj->nodesetval->nodeNr; i++) {			(*func) (xpathObj->nodesetval->nodeTab[i], user_data);			xpathObj->nodesetval->nodeTab[i] = NULL ;		}	}		if (xpathObj)		xmlXPathFreeObject (xpathObj);}
开发者ID:814ckf0x,项目名称:liferea,代码行数:21,



注:本文中的xmlXPathEval函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ xmlXPathEvalExpression函数代码示例
C++ xmlXPathCheckError函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。