当前位置: 首页>>代码示例>>C++>>正文


C++ xmlXPathEval函数代码示例

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


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

示例1: xslDbgShellCat

int
xslDbgShellCat(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,代码来源:nodeview_cmds.cpp

示例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,代码来源:simbatch_config.c

示例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,代码来源:XPathContext.cpp

示例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,代码来源:main.cpp

示例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.
 */
xmlNodePtr
virXPathNode(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,代码来源:virxml.c

示例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.
 */
int
virXPathNumber(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,代码来源:virxml.c

示例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,代码来源:virsh-volume.c

示例8: exsltDynEvaluateFunction

static void
exsltDynEvaluateFunction(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,代码来源:dynamic.c

示例9: seed_xml_xpath_eval

static SeedValue
seed_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,代码来源:seed-libxml.c

示例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,代码来源:parser.c

示例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,代码来源:xml_config.c

示例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.
 */
int
virXPathLongLong(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,代码来源:virxml.c

示例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,代码来源:virxml.c

示例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,代码来源:msg.c

示例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.
 */
int
virXPathBoolean(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,代码来源:virxml.c


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