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

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

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

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

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

示例1: subdesc_create_hashtable

/***************************************************************************** 函 数 名  : subdesc_create_hashtable 功能描述  : 根据doc中包括的有name的元素的数量创建hash表 输入参数  : doc sub文档 root 结构指针 输出参数  : 无 返 回 值  : ERR_SUCCESS成功 其他失败 调用函数  : 被调函数  : ============================================================================ 修改历史      :  1.日    期   : 2008年8月26日        修改内容   : 新生成函数*****************************************************************************/static int subdesc_create_hashtable(xmlDocPtr doc, SUB_ROOT * root){    xmlXPathContextPtr xpathCtx;    int ret = ERROR_SUCCESS;    /* Create xpath evaluation context */    xpathCtx = xmlXPathNewContext(doc);    if(xpathCtx == NULL)    {        return ERROR_SYSTEM;    }    xmlXPathObjectPtr xpathObj;    /* Evaluate xpath expression */    xpathObj = xmlXPathEvalExpression((unsigned char*)"//*[@name]", xpathCtx);    if(xpathObj != NULL)    {        if(NULL == xpathObj->nodesetval ||           xpathObj->nodesetval->nodeNr ==0 ||           0 == hcreate_r(xpathObj->nodesetval->nodeNr,                   (struct hsearch_data *)(root->_hashtable)))        {            ret = ERROR_SYSTEM;        }        xmlXPathFreeObject(xpathObj);    }    else    {        ret = ERROR_SYSTEM;    }    xmlXPathFreeContext(xpathCtx);    return ret;}
开发者ID:millken,项目名称:zhuxianB30,代码行数:52,


示例2: xmlSecXPathDataCreate

static xmlSecXPathDataPtrxmlSecXPathDataCreate(xmlSecXPathDataType type) {    xmlSecXPathDataPtr data;    data = (xmlSecXPathDataPtr) xmlMalloc(sizeof(xmlSecXPathData));    if(data == NULL) {        xmlSecMallocError(sizeof(xmlSecXPathData), NULL);        return(NULL);    }    memset(data, 0, sizeof(xmlSecXPathData));    data->type = type;    data->nodeSetType = xmlSecNodeSetTree;    /* create xpath or xpointer context */    switch(data->type) {    case xmlSecXPathDataTypeXPath:    case xmlSecXPathDataTypeXPath2:        data->ctx = xmlXPathNewContext(NULL); /* we'll set doc in the context later */        if(data->ctx == NULL) {            xmlSecXmlError("xmlXPathNewContext", NULL);            xmlSecXPathDataDestroy(data);            return(NULL);        }        break;    case xmlSecXPathDataTypeXPointer:        data->ctx = xmlXPtrNewContext(NULL, NULL, NULL); /* we'll set doc in the context later */        if(data->ctx == NULL) {            xmlSecXmlError("xmlXPtrNewContext", NULL);            xmlSecXPathDataDestroy(data);            return(NULL);        }        break;    }    return(data);}
开发者ID:esproul,项目名称:xmlsec,代码行数:37,


示例3: get_java_home

xmlChar* get_java_home(char *current_path){	char path_to_bbwp_properties[PATH_MAX+1];		strncpy(path_to_bbwp_properties, current_path, PATH_MAX+1);	strncat(path_to_bbwp_properties, "/bin/bbwp.properties", PATH_MAX+1);		xmlDocPtr doc = xmlParseFile(path_to_bbwp_properties);	if (doc == NULL) {		printf("error: could not parse file %s/n", path_to_bbwp_properties);	}		xmlXPathContextPtr context = xmlXPathNewContext(doc);	xmlChar * xpath = "/wcp/java";	xmlNodeSetPtr nodeset;	xmlXPathObjectPtr result = xmlXPathEvalExpression(xpath, context);	xmlChar *java_home;		if(xmlXPathNodeSetIsEmpty(result->nodesetval)){		printf("No result/n");	} else {        nodeset = result->nodesetval;        java_home = xmlNodeListGetString(doc, nodeset->nodeTab[0]->xmlChildrenNode, 1);	}		xmlFreeDoc(doc);	xmlXPathFreeContext(context);	xmlXPathFreeObject(result);		/*	 * Free the global variables that may	 * have been allocated by the parser.	 */	xmlCleanupParser();		return java_home;}
开发者ID:adrianlee,项目名称:BBX-Packager,代码行数:37,


示例4: parallelsDiskDescParseNode

static int parallelsDiskDescParseNode(xmlDocPtr xml,                                      xmlNodePtr root,                                      virStorageVolDefPtr def){    xmlXPathContextPtr ctxt = NULL;    int ret = -1;    if (STRNEQ((const char *)root->name, "Parallels_disk_image")) {        virReportError(VIR_ERR_XML_ERROR,                       "%s", _("unknown root element for storage pool"));        goto cleanup;    }    ctxt = xmlXPathNewContext(xml);    if (ctxt == NULL) {        virReportOOMError();        goto cleanup;    }    ctxt->node = root;    if (virXPathULongLong("string(./Disk_Parameters/Disk_size)",                          ctxt, &def->target.capacity) < 0) {        virReportError(VIR_ERR_XML_ERROR,                       "%s", _("failed to get disk size from "                               "the disk descriptor xml"));        goto cleanup;    }    def->target.capacity <<= 9;    def->target.allocation = def->target.capacity;    ret = 0; cleanup:    xmlXPathFreeContext(ctxt);    return ret;}
开发者ID:CLisa,项目名称:libvirt,代码行数:37,


示例5: RS_XML_xpathNodeEval

SEXPRS_XML_xpathNodeEval(SEXP s_node, SEXP path, SEXP namespaces, SEXP fun){ xmlXPathContextPtr ctxt = NULL; xmlXPathObjectPtr result; SEXP ans = NULL_USER_OBJECT; xmlDocPtr doc; if(TYPEOF(s_node) != EXTPTRSXP || R_ExternalPtrTag(s_node) != Rf_install("XMLInternalNode")) {   PROBLEM "xpathEval must be given an internal XML document object, 'XMLInternalNode'"   ERROR; } ctxt = xmlXPathNewContext(doc); if(GET_LENGTH(namespaces)) {     ctxt->namespaces =  R_namespaceArray(namespaces, ctxt); /* xmlCopyNamespaceList(doc); */     ctxt->nsNr = GET_LENGTH(namespaces); } result = xmlXPathEvalExpression(CHAR_TO_XMLCHAR(CHAR_DEREF(STRING_ELT(path, 0))), ctxt); if(result)     ans = convertXPathObjectToR(result, fun);  xmlXPathFreeObject(result); xmlXPathFreeContext(ctxt); if(!result) {   PROBLEM  "error evaluating xpath expression %s", CHAR_DEREF(STRING_ELT(path, 0))   ERROR; } return(ans);}
开发者ID:jetaber,项目名称:XML,代码行数:37,


示例6: new_child_node

void new_child_node (const char* filename, const xmlChar* xpathExpr,                     const xmlChar *name, const xmlChar *content){	xmlDocPtr doc;	xmlXPathContextPtr xpathCtx;	xmlXPathObjectPtr xpathObj;	xmlKeepBlanksDefault(0);	/* Load XML document */	doc = xmlParseFile(filename);	if (doc == NULL) {		fprintf(stderr, "Error: unable to parse file /"%s/"/n", filename);		return;	}	/* Create xpath evaluation context */	xpathCtx = xmlXPathNewContext(doc);	if(xpathCtx == NULL) {		fprintf(stderr,"Error: unable to create new XPath context/n");		xmlFreeDoc(doc); 		return;	}	/* Evaluate xpath expression */	xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);	if(xpathObj == NULL) {		fprintf(stderr,"Error: unable to evaluate xpath expression /"%s/"/n", xpathExpr);		xmlXPathFreeContext(xpathCtx);		xmlFreeDoc(doc); 		return;	}	xmlNewTextChild (xpathObj->nodesetval->nodeTab[0], NULL, name, content);	xmlXPathFreeObject(xpathObj);                                 	xmlXPathFreeContext(xpathCtx);	xmlSaveFormatFile (filename, doc, 1);	xmlFreeDoc(doc);}
开发者ID:thof,项目名称:GSTranslator,代码行数:37,


示例7: flickcurl_auth_checkToken

/** * flickcurl_auth_checkToken: * @fc: flickcurl context * @token: token string *  * Get the credentials attached to an authentication token. * * Implements flickr.auth.checkToken (0.9) * Must be signed. *  * FIXME: Cannot confirm this works, get intermittent results. * * Return value: permissions string or NULL on failure **/char*flickcurl_auth_checkToken(flickcurl* fc, const char* token){  const char * parameters[6][2];  int count = 0;  char *perms = NULL;  xmlDocPtr doc = NULL;  xmlXPathContextPtr xpathCtx = NULL;   if(!token)    return NULL;    parameters[count][0]   = "auth_token";  parameters[count++][1] = (char*)token;  parameters[count][0]   = NULL;  flickcurl_set_sign(fc);    if(flickcurl_prepare(fc, "flickr.auth.checkToken", parameters, count))    goto tidy;  doc = flickcurl_invoke(fc);  if(!doc)    goto tidy;    xpathCtx = xmlXPathNewContext(doc);  if(xpathCtx) {    perms = flickcurl_xpath_eval(fc, xpathCtx,                                    (const xmlChar*)"/rsp/auth/perms");    xmlXPathFreeContext(xpathCtx);  }  tidy:  return perms;}
开发者ID:yangxq,项目名称:flickcurl,代码行数:51,


示例8: flickcurl_people_getUploadStatus

/** * flickcurl_people_getUploadStatus: * @fc: flickcurl context *  * Returns information for the calling user related to photo uploads. * * Implements flickr.people.getUploadStatus (0.13) *  * Return value: non-0 on failure **/flickcurl_user_upload_status*flickcurl_people_getUploadStatus(flickcurl* fc){  const char* parameters[7][2];  int count=0;  xmlDocPtr doc=NULL;  xmlXPathContextPtr xpathCtx=NULL;   flickcurl_user_upload_status* status=NULL;    parameters[count][0]  = NULL;  if(flickcurl_prepare(fc, "flickr.people.getUploadStatus", parameters, count))    goto tidy;  doc=flickcurl_invoke(fc);  if(!doc)    goto tidy;  xpathCtx = xmlXPathNewContext(doc);  if(!xpathCtx) {    flickcurl_error(fc, "Failed to create XPath context for document");    fc->failed=1;    goto tidy;  }  status=flickcurl_build_user_upload_status(fc, xpathCtx, (const xmlChar*)"/rsp/user/*");  tidy:  if(xpathCtx)    xmlXPathFreeContext(xpathCtx);  if(fc->failed)    status=NULL;  return status;}
开发者ID:Huge,项目名称:flickcurl,代码行数:47,


示例9: flickcurl_people_getInfo

/** * flickcurl_people_getInfo: * @fc: flickcurl context * @user_id: user NSID *  * Get information about a person * * Implements flickr.people.getInfo (0.6) * * NSID can be found by flickcurl_people_findByEmail() or * flickcurl_people_findByUsername(). *  * Return value: #flickcurl_person object or NULL on failure **/flickcurl_person*flickcurl_people_getInfo(flickcurl* fc, const char* user_id){  xmlDocPtr doc = NULL;  xmlXPathContextPtr xpathCtx = NULL;   flickcurl_person* person = NULL;    flickcurl_init_params(fc, 0);  flickcurl_add_param(fc, "user_id", user_id);  flickcurl_end_params(fc);  if(flickcurl_prepare(fc, "flickr.people.getInfo"))    goto tidy;  doc = flickcurl_invoke(fc);  if(!doc)    goto tidy;  xpathCtx = xmlXPathNewContext(doc);  if(!xpathCtx) {    flickcurl_error(fc, "Failed to create XPath context for document");    fc->failed = 1;    goto tidy;  }  person = flickcurl_build_person(fc, xpathCtx, (const xmlChar*)"/rsp/person"); tidy:  if(xpathCtx)    xmlXPathFreeContext(xpathCtx);  if(fc->failed)    person = NULL;  return person;}
开发者ID:Web5design,项目名称:flickcurl,代码行数:51,


示例10: xmlXPathNewContext

std::string OSConfigure::readonestring ( std::string path ){    xmlChar * xpath = ( xmlChar * ) path.c_str ();    xmlChar *keyword;    std::string retstring;    xmlNodeSetPtr nodeset;    xmlXPathContextPtr context;    xmlXPathObjectPtr result;    context = xmlXPathNewContext ( doc );    if ( context == NULL )        return "";    result = xmlXPathEvalExpression ( xpath, context );    xmlXPathFreeContext ( context );    if ( result == NULL )        return "";    if ( xmlXPathNodeSetIsEmpty ( result->nodesetval ) )    {        return "";    }    nodeset = result->nodesetval;    keyword = xmlNodeListGetString ( doc, nodeset->nodeTab[ 0 ] ->xmlChildrenNode, 1 );    if ( keyword != NULL )        retstring = std::string ( ( char * ) keyword );    xmlFree ( keyword );    xmlXPathFreeObject ( result );    return retstring;}
开发者ID:BackupTheBerlios,项目名称:openspace-svn,代码行数:37,


示例11: lock

// Evaluate an XPath expression and return matching Nodes.NodeList Document::findXPath(const std::string& path) const{	std::lock_guard<std::mutex> lock(_lock);    // Set up the XPath context    xmlXPathContextPtr context = xmlXPathNewContext(_xmlDoc);    if (context == NULL) {        rConsoleError() << "ERROR: xml::findPath() failed to create XPath context "                  << "when searching for " << path << std::endl;        throw XPathException("Failed to create XPath context");    }    // Evaluate the expression    const xmlChar* xpath = reinterpret_cast<const xmlChar*>(path.c_str());    xmlXPathObjectPtr result = xmlXPathEvalExpression(xpath, context);    xmlXPathFreeContext(context);    if (result == NULL) {        rConsoleError() << "ERROR: xml::findPath() failed to evaluate expression "                  << path << std::endl;        throw XPathException("Failed to evaluate XPath expression");    }    // Construct the return vector. This may be empty if the provided XPath    // expression does not identify any nodes.    NodeList retval;    xmlNodeSetPtr nodeset = result->nodesetval;	if (nodeset != NULL) {	    for (int i = 0; i < nodeset->nodeNr; i++) {	        retval.push_back(Node(nodeset->nodeTab[i]));	    }	}    xmlXPathFreeObject(result);    return retval;}
开发者ID:codereader,项目名称:DarkRadiant,代码行数:38,


示例12: get_nodes_with_name_xpath

xmlXPathObjectPtr get_nodes_with_name_xpath( XMLDoc *tree, FeriteString *str ) {    char *xpath, *x = "descendant-or-self::node()";	    xmlXPathCompExprPtr comp = NULL;    int length = strlen( x ) + str->length + 4;        xpath = malloc(length);    memset(xpath, '/0', length );    sprintf( xpath, "%s/%s", x, str->data );    comp = xmlXPathCompile( BAD_CAST xpath );    free(xpath);        if( comp != NULL ) {        xmlXPathObjectPtr res = NULL;         xmlXPathContextPtr ctxt = xmlXPathNewContext( tree->doc );                ctxt->node = tree->node;        res = xmlXPathCompiledEval( comp, ctxt );        xmlXPathFreeContext( ctxt );        xmlXPathFreeCompExpr( comp );          return res;    }    return NULL;}
开发者ID:RichardMarks,项目名称:ferite,代码行数:24,


示例13: process_recursive

int process_recursive(xmlDocPtr doc, char *xpath, int level, char *fn){    int i, num;    xmlXPathContextPtr context;    xmlXPathObjectPtr op;    xmlNodeSetPtr nodeset;    context = xmlXPathNewContext(doc);    if (context == NULL) {        DPRINTF("Error in xmlXPathNewContext/n");        return 0;    }    DPRINTF("Trying to access xPath node %s/n", xpath);    op = xmlXPathEvalExpression( (xmlChar *)xpath, context);    xmlXPathFreeContext(context);    if (op == NULL) {        DPRINTF("Error in xmlXPathEvalExpression/n");        return -EIO;    }    if(xmlXPathNodeSetIsEmpty(op->nodesetval)) {        xmlXPathFreeObject(op);        DPRINTF("No result/n");        return -EINVAL;    }    nodeset = op->nodesetval;    num = nodeset->nodeNr;    for (i = 0; i < num; i++)        process_data(doc, nodeset->nodeTab[i], xpath, level, fn);    xmlXPathFreeObject(op);    return 0;}
开发者ID:MigNov,项目名称:CDVWS,代码行数:36,


示例14: getnodeset

xmlXPathObjectPtrgetnodeset (xmlDocPtr doc, xmlChar *xpath) {		xmlXPathContextPtr context;	xmlXPathObjectPtr result;	context = xmlXPathNewContext(doc);	if (context == NULL) {		printf("[ getnodeset ] : [ ERROR ] :  xmlXPathNewContext/n");		return NULL;	}	result = xmlXPathEvalExpression(xpath, context);	xmlXPathFreeContext(context);	if (result == NULL) {		printf("[ getnodeset ] : [ ERROR ] : xmlXPathEvalExpression/n");		return NULL;	}	if(xmlXPathNodeSetIsEmpty(result->nodesetval)){		xmlXPathFreeObject(result);        if(DEBUG>2) printf("[ getnodeset ] : [ WARNING ] :  no xmlXPath result found/n");		return NULL;	}	return result;}
开发者ID:perhansson,项目名称:svt-epics,代码行数:24,


示例15: parse_ref_tag

static struct ldap_object_node *parse_ref_tag(xmlNodePtr curr_node,    	      struct ldap_object_node **objs,	      struct ldap_attr_node **attrs,	      struct idinfo *ids){	xmlXPathObjectPtr xobj;	xmlXPathContextPtr xctx;	char query[1024];	char *n;		dbg_printf("Trying to parse ref tag/n");	n = (char *)xmlGetProp(curr_node, (xmlChar *)"name");	snprintf(query, sizeof(query), "//define[@name=/"%s/"]", n);	xctx = xmlXPathNewContext(curr_node->doc);	assert(xctx);	xobj = xmlXPathEvalExpression((xmlChar *)query, xctx);	printf("%d nodes match %s/n", xobj->nodesetval->nodeNr, query);	assert(0);	return NULL;}
开发者ID:smintz,项目名称:cluster,代码行数:24,


示例16: testXPath

static voidtestXPath(const char *str) {    xmlXPathObjectPtr res;    xmlXPathContextPtr ctxt;#if defined(LIBXML_XPTR_ENABLED)    if (xptr) {	ctxt = xmlXPtrNewContext(document, NULL, NULL);	res = xmlXPtrEval(BAD_CAST str, ctxt);    } else {#endif	ctxt = xmlXPathNewContext(document);	ctxt->node = xmlDocGetRootElement(document);	if (expr)	    res = xmlXPathEvalExpression(BAD_CAST str, ctxt);	else {	    /* res = xmlXPathEval(BAD_CAST str, ctxt); */	    xmlXPathCompExprPtr comp;	    comp = xmlXPathCompile(BAD_CAST str);	    if (comp != NULL) {		if (tree)		    xmlXPathDebugDumpCompExpr(stdout, comp, 0);		res = xmlXPathCompiledEval(comp, ctxt);		xmlXPathFreeCompExpr(comp);	    } else		res = NULL;	}#if defined(LIBXML_XPTR_ENABLED)    }#endif    xmlXPathDebugDumpObject(stdout, res, 0);    xmlXPathFreeObject(res);    xmlXPathFreeContext(ctxt);}
开发者ID:tman0103,项目名称:libxml2,代码行数:36,


示例17: addForbiddenKey

voidXmlConfig::subKeys(const std::string &key, std::vector<std::string> &v) const {    addForbiddenKey(key + "/*");        XmlXPathContextHelper xctx(xmlXPathNewContext(data_->doc_.get()));    XmlUtils::throwUnless(NULL != xctx.get());    XmlXPathObjectHelper object(xmlXPathEvalExpression((const xmlChar*) key.c_str(), xctx.get()));    XmlUtils::throwUnless(NULL != object.get());    if (NULL != object->nodesetval && 0 != object->nodesetval->nodeNr) {        xmlNodeSetPtr ns = object->nodesetval;        v.reserve(ns->nodeNr);        for (int i = 0; i < ns->nodeNr; ++i) {            XmlUtils::throwUnless(NULL != ns->nodeTab[i]);            std::stringstream stream;            stream << key << "[" << (i + 1) << "]";            v.push_back(stream.str());        }    }}
开发者ID:bacek,项目名称:xscript,代码行数:24,


示例18: config_load

config_t *config_load(const char *config_file){    config_t *c;        c = malloc(sizeof(*c));    if (!c)        return NULL;        /* Analyse du fichier */    c->doc = xmlParseFile(config_file);    if (!c->doc) {        free(c);        return NULL;    }        /* Recherche du noeud racine */    c->root = xmlDocGetRootElement(c->doc);        xmlXPathInit();    c->context = xmlXPathNewContext(c->doc);        return c;}
开发者ID:frs69wq,项目名称:Simbatch,代码行数:24,


示例19: cx_parse_xml

static int cx_parse_xml(cx_t *db, char *xml) /* {{{ */{  /* Load the XML */  xmlDocPtr doc = xmlParseDoc(BAD_CAST xml);  if (doc == NULL) {    ERROR("curl_xml plugin: Failed to parse the xml document  - %s", xml);    return -1;  }  xmlXPathContextPtr xpath_ctx = xmlXPathNewContext(doc);  if (xpath_ctx == NULL) {    ERROR("curl_xml plugin: Failed to create the xml context");    xmlFreeDoc(doc);    return -1;  }  for (size_t i = 0; i < db->namespaces_num; i++) {    cx_namespace_t const *ns = db->namespaces + i;    int status =        xmlXPathRegisterNs(xpath_ctx, BAD_CAST ns->prefix, BAD_CAST ns->url);    if (status != 0) {      ERROR("curl_xml plugin: "            "unable to register NS with prefix=/"%s/" and href=/"%s/"/n",            ns->prefix, ns->url);      xmlXPathFreeContext(xpath_ctx);      xmlFreeDoc(doc);      return status;    }  }  int status = cx_handle_parsed_xml(db, doc, xpath_ctx);  /* Cleanup */  xmlXPathFreeContext(xpath_ctx);  xmlFreeDoc(doc);  return status;} /* }}} cx_parse_xml */
开发者ID:EMSL-MSC,项目名称:collectd,代码行数:36,


示例20: string

xmlXPathObjectPtr TrackerConfig::findConfigNodes(const string& sXPathExpr) const{    string sFullPath = string("/trackerconfig"+sXPathExpr);    xmlXPathContextPtr xpCtx;    xmlXPathObjectPtr xpElement;    xpCtx = xmlXPathNewContext(m_Doc);    if(!xpCtx) {        AVG_LOG_ERROR("Unable to create new XPath context");        return NULL;    }    xpElement = xmlXPathEvalExpression(BAD_CAST sFullPath.c_str(), xpCtx);    if(!xpElement) {        AVG_LOG_ERROR("Unable to evaluate XPath expression '"            << sFullPath << "'");        xmlXPathFreeContext(xpCtx);        return NULL;    }        xmlXPathFreeContext(xpCtx);    return xpElement;}
开发者ID:JohnChu,项目名称:libavg,代码行数:24,


示例21: parse_rss_item

bool parse_rss_item(xmlNodePtr node, wxString &url, wxString &version, wxString &md5, wxDateTime &datetime) {	xmlXPathContextPtr xp_ctx = xmlXPathNewContext(node->doc);	xp_ctx->node = node;	int ret;	ret = xmlXPathRegisterNs(xp_ctx,			BAD_CAST "media",			BAD_CAST "http://video.search.yahoo.com/mrss/");	assert(ret == 0);	wxString datetime_string;	wxString* str_array[] = { &md5, &url, &datetime_string };	const char * xpath_array[] = { "./media:content/media:hash[@algo='md5']", "./link", "./pubDate" };	for (size_t i = 0; i < sizeof(str_array) / sizeof(str_array[0]); i++) {		xmlNodePtr _node = uxmlXPathGetNode(BAD_CAST xpath_array[i], xp_ctx);		if (_node == NULL || _node->xmlChildrenNode == NULL) {				xmlXPathFreeContext(xp_ctx);				return false;		}		xmlChar* _str = xmlNodeListGetString(_node->doc, _node->xmlChildrenNode, 1);		*str_array[i] = SC::U2S(_str);		xmlFree(_str);	}	if (datetime.ParseRfc822Date(datetime_string.c_str()) == NULL) {		xmlXPathFreeContext(xp_ctx);		return false;	}	version = url2version(url);	return true;}
开发者ID:cyclefusion,项目名称:szarp,代码行数:36,


示例22: xml_GetNodeSet

xmlXPathObjectPtr static xml_GetNodeSet(xmlDocPtr doc, const xmlChar *pXpath) {	xmlXPathContextPtr context = NULL;	    	xmlXPathObjectPtr xpRet = NULL;		    if(doc == NULL || pXpath == NULL) return xpRet;	{		context = xmlXPathNewContext(doc);				if (context != NULL) 		{				xpRet = xmlXPathEvalExpression(pXpath, context); 			xmlXPathFreeContext(context);							if (xpRet != NULL) 			{				if (xmlXPathNodeSetIsEmpty(xpRet->nodesetval))   				{					xmlXPathFreeObject(xpRet);					xpRet = NULL;				}			}		}	}	return xpRet;	}
开发者ID:ADVANTECH-Corp,项目名称:WISEAgent,代码行数:24,


示例23: retrieve_all_elements

/* * Use XPath for the search. Find all elements with the name specified by user. * Return - pointer to the list of elements or NULL if an error occurred. */xmlXPathObjectPtr retrieve_all_elements(xmlDocPtr doc, char *element){	xmlXPathContextPtr context;	xmlXPathObjectPtr result;	context = xmlXPathNewContext(doc);	if (context == NULL){		printf("Error in xmlXPathNewContext/n");		return NULL;	}		result = xmlXPathEvalExpression((xmlChar *)element, context);		xmlXPathFreeContext(context);	if (result == NULL){		printf("Error in xmlXPathEvalExpression/n");		return NULL;	}	if (xmlXPathNodeSetIsEmpty(result->nodesetval)){		xmlXPathFreeObject(result);		printf("No result./n");		return NULL;	}	return result;}
开发者ID:CrypticGator,项目名称:iio-oscilloscope,代码行数:28,


示例24: parse_and_write_xml_data

intparse_and_write_xml_data(const char *station_id, htmlDocPtr doc, const char *result_file){    char        buff[256],                buffer[buff_size];    char        temp_buffer[buff_size];    int         size;    int         i,j;    xmlXPathContextPtr xpathCtx;     xmlXPathObjectPtr xpathObj = NULL;     xmlXPathObjectPtr xpathObj2 = NULL;     xmlXPathObjectPtr xpathObj3 = NULL;     xmlXPathObjectPtr xpathObj4 = NULL;     xmlXPathObjectPtr xpathObj5 = NULL;     xmlXPathObjectPtr xpathObj6 = NULL;     xmlXPathObjectPtr xpathObj7 = NULL;     xmlNodeSetPtr nodes;    char       *temp_char;    struct tm   tmp_tm = {0};    struct tm   *tm;    time_t      t_start = 0, t_end = 0,                current_time = 0;    FILE        *file_out;    file_out = fopen(result_file, "w");    if (!file_out)        return -1;    fprintf(file_out,"<?xml version=/"1.0/" encoding=/"UTF-8/"?>/n<station name=/"Station name/" id=/"%s/" xmlns=/"http://omweather.garage.maemo.org/schemas/">/n", station_id);    fprintf(file_out," <units>/n  <t>C</t>/n  <ws>m/s</ws>/n  <wg>m/s</wg>/n  <d>km</d>/n");    fprintf(file_out,"  <h>%%</h>  /n  <p>mmHg</p>/n </units>/n");    /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */    hash_for_icons = hash_icons_forecacom_table_create();    /* Create xpath evaluation context */    xpathCtx = xmlXPathNewContext(doc);    if(xpathCtx == NULL) {        fprintf(stderr,"Error: unable to create new XPath context/n");         return(-1);    }    /* Register namespaces from list (if any) */    xmlXPathRegisterNs(xpathCtx, (const xmlChar*)"html",                                (const xmlChar*)"http://www.w3.org/1999/xhtml");    /* Day weather forecast */    /* Evaluate xpath expression */    xpathObj = xmlXPathEvalExpression((const xmlChar*)"/html/body/*/div[(@data-ts)]/@data-ts", xpathCtx);//    xpathObj = xmlXPathEvalExpression((const xmlChar*)"/html/body/div/div/table//tr/th[@colspan='3']", xpathCtx);      if(xpathObj == NULL) {        fprintf(stderr,"Error: unable to evaluate xpath expression /"%s/"/n", "/html/body/*/div[(@data-ts)]/@data-ts");        xmlXPathFreeContext(xpathCtx);         return(-1);    }    nodes   = xpathObj->nodesetval;    size = (nodes) ? nodes->nodeNr : 0;    if (size > 14)        size = 14;    /* fprintf(stderr, "SIZE!!!!!!!!!!!!!!: %i/n", size); */    xpathObj2 = xmlXPathEvalExpression((const xmlChar*)"/html/body/*/div[(@data-ts)]/div/span[(@class='temp_max temp_warm') or (@class='temp_max temp_cold')]/text()", xpathCtx);    xpathObj3 = xmlXPathEvalExpression((const xmlChar*)"/html/body/*/div[(@data-ts)]/div/span[(@class='temp_min')]/text()", xpathCtx);    xpathObj4 = xmlXPathEvalExpression((const xmlChar*)"/html/body/*/div[(@data-ts)]/div/div/@class", xpathCtx);    xpathObj5 = xmlXPathEvalExpression((const xmlChar*)"/html/body/*/div[(@data-ts)]/div/strong/text()", xpathCtx);    xpathObj6 = xmlXPathEvalExpression((const xmlChar*)"/html/body/*/div[(@data-ts)]/div/img/@src", xpathCtx);    xpathObj7 = xmlXPathEvalExpression((const xmlChar*)"/html/body/*/div[(@data-ts)]/div/img/@title", xpathCtx);      /* fprintf(stderr, "Result (%d nodes):/n", size); */    for(i = 0; i < size; ++i) {         /* Take time: */         if (!nodes->nodeTab[i]->children->content){             fprintf(stderr,"ERRROR");             continue;         }         /* fprintf(stderr," TEXT %s/n", nodes->nodeTab[i]->children->content); */          current_time = time(NULL);         tm = localtime(&current_time);         setlocale(LC_TIME, "POSIX");         strptime((const char*)nodes->nodeTab[i]->children->content, "%Y%m%d", &tmp_tm);         setlocale(LC_TIME, "");         /* set begin of day in localtime */         tmp_tm.tm_year = tm->tm_year;         tmp_tm.tm_hour = 0; tmp_tm.tm_min = 0; tmp_tm.tm_sec = 0;         t_start = mktime(&tmp_tm);         fprintf(file_out,"    <period start=/"%li/"", t_start);         /* set end of day in localtime */         t_end = t_start + 3600*24 - 1;         fprintf(file_out," end=/"%li/">/n", t_end);              /* added hi temperature */         if (xpathObj2 && !xmlXPathNodeSetIsEmpty(xpathObj2->nodesetval) &&             xpathObj2->nodesetval->nodeTab[i] && xpathObj2->nodesetval->nodeTab[i]->content){             /* fprintf (stderr, "temperature %s/n", xpathObj2->nodesetval->nodeTab[i]->content); */             snprintf(buffer, sizeof(buffer)-1,"%s", xpathObj2->nodesetval->nodeTab[i]->content);             memset(temp_buffer, 0, sizeof(temp_buffer));             for (j = 0 ; (j<(strlen(buffer)) && j < buff_size); j++ ){                 if (buffer[j] == '&')                    break;                 if ((uint)buffer[j] == 226 ||  buffer[j] == '-' ||                      (buffer[j]>='0' && buffer[j]<='9')){//.........这里部分代码省略.........
开发者ID:foolab,项目名称:meecast,代码行数:101,


示例25: parse_and_write_detail_data

intparse_and_write_detail_data(const char *station_id, htmlDocPtr doc, const char *result_file){    char       buff[256];    char       buffer[buff_size];    char       temp_buffer[buff_size];    int        j, k, l;    xmlXPathContextPtr xpathCtx;     xmlXPathObjectPtr xpathObj = NULL;     xmlXPathObjectPtr xpathObj2 = NULL;     xmlNodeSetPtr nodes;    char       *temp_char;    char       *temp_char2;    int        pressure;     int        speed;    int        ppcp;    char       *image = NULL;    double      time_diff = 0;    time_t      loc_time;    time_t      utc_time;    int        location_timezone = 0;    int    flag;    struct tm   tmp_tm = {0};    struct tm   *tm;    time_t      t_start = 0, t_end = 0,                t_sunrise = 0, t_sunset = 0,                current_time = 0;    FILE        *file_out;    int index = 1;    struct tm time_tm1;    struct tm time_tm2;    int localtimezone = 0;    int remotetimezone = 0;    int hour = 0;    int day = 0;    int month = 0;    char buff_day[256];    /* fprintf(stderr, "parse_and_write_detail_data()/n"); */    file_out = fopen(result_file, "a");    if (!file_out)        return -1;    /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */    hash_for_icons = hash_icons_forecacom_table_create();    /* Create xpath evaluation context */    xpathCtx = xmlXPathNewContext(doc);    if(xpathCtx == NULL) {        fprintf(stderr,"Error: unable to create new XPath context/n");         return(-1);    }    /* Register namespaces from list (if any) */    xmlXPathRegisterNs(xpathCtx, (const xmlChar*)"html",                                (const xmlChar*)"http://www.w3.org/1999/xhtml");    /* Current weather forecast */    /* Evaluate xpath expression */    xpathObj = xmlXPathEvalExpression((const xmlChar*)"/html/body/div[@id='cc']/div[@class='cctext']/p/text()[3]", xpathCtx);      if(xpathObj == NULL) {        fprintf(stderr,"Error: unable to evaluate xpath expression /"%s/"/n", " /html/body/div[@id='cc']/div[@class='cctext']/p/text()[3]");        xmlXPathFreeContext(xpathCtx);         return(-1);    }    if (xpathObj->nodesetval == NULL || xpathObj->nodesetval->nodeTab == NULL || xpathObj->nodesetval->nodeTab[0] ==NULL || xpathObj->nodesetval->nodeTab[0]->content == NULL){                xpathObj = xmlXPathEvalExpression((const xmlChar*)"/html/body/div[@id='cc']/div[@class='cctext']/p/text()[2]", xpathCtx);        if (xpathObj->nodesetval == NULL || xpathObj->nodesetval->nodeTab == NULL || xpathObj->nodesetval->nodeTab[0] ==NULL || xpathObj->nodesetval->nodeTab[0]->content == NULL){            xmlXPathFreeContext(xpathCtx);             return -1;        }    }    /* Set localtimezone */    current_time = time(NULL);    gmtime_r(&current_time, &time_tm1);    localtime_r(&current_time, &time_tm2);    localtimezone = (mktime(&time_tm2) - mktime(&time_tm1))/3600;     /* fprintf(stderr,"Local Time Zone %i/n", localtimezone); */    if (xpathObj && xpathObj->nodesetval->nodeTab[0]->content){        tm = localtime(&current_time);        snprintf(buffer, sizeof(buffer)-1,"%i %s", tm->tm_year + 1900, xpathObj->nodesetval->nodeTab[0]->content);        /* fprintf(stderr, "Time %s", buffer); */        setlocale(LC_TIME, "POSIX");        strptime((const char*)buffer, "%Y%n%d/%m %H", &tmp_tm);        hour = tmp_tm.tm_hour;         day = tmp_tm.tm_mday;        month = tmp_tm.tm_mon;        if (xpathObj)            xmlXPathFreeObject(xpathObj);        xpathObj = xmlXPathEvalExpression((const xmlChar*)"/html/body/div[@class='hourlyfc']/*[@class='symbcol']/preceding-sibling::div[@class='timecol']/p/text()", xpathCtx);        if (xpathObj && xpathObj->nodesetval->nodeTab[0]->content){            int hour = atoi((const char*)xpathObj->nodesetval->nodeTab[0]->content) -1;            tmp_tm.tm_hour = hour;        }        time_tm1.tm_min = 0;        tmp_tm.tm_min = 0;//.........这里部分代码省略.........
开发者ID:foolab,项目名称:meecast,代码行数:101,


示例26: dict_get_translate

GPtrArray * dict_get_translate(const gchar * keyword){	gchar * key_url = NULL;	htmlDocPtr html_doc = NULL;	xmlDocPtr doc = NULL;	xmlNodePtr clone = NULL;	xmlXPathContextPtr ctx = NULL;	xmlXPathObjectPtr obj = NULL;	xmlNodeSetPtr nodeset = NULL;	gchar * tmp_str = NULL;	GPtrArray * result = NULL;	gint i;	key_url = g_strjoin(NULL, KEY_URL_PREFIX, keyword, KEY_URL_SUFIX, NULL);	g_debug("KEY-URL: %s", key_url);	html_doc = htmlReadFile(key_url, NULL, HTML_PARSE_NOWARNING | HTML_PARSE_NOERROR);	if (!html_doc)	{		g_message("KEY-URL %s get failed", key_url);		goto out;	}	ctx = xmlXPathNewContext((xmlDocPtr)html_doc);	if (!ctx)	{		g_message("XPath context creat failed");		goto out;	}	obj = xmlXPathEvalExpression(KEY_WORD_XPATH, ctx);	if (!obj)	{		g_message("XPath eval key word xpath failed");		goto out;	}	if (xmlXPathNodeSetIsEmpty(obj->nodesetval))	{		g_message("XPath search keyword failed");		goto out;	}	nodeset = obj->nodesetval;	g_debug("Key word node set have %d object", nodeset->nodeNr);	clone = xmlCopyNode(nodeset->nodeTab[0], 1);	if (!clone)		goto out;	doc = xmlNewDoc("1.0");	if (!doc)		goto out;	xmlDocSetRootElement(doc, clone);	xmlXPathFreeContext(ctx);	ctx = NULL;	xmlXPathFreeObject(obj);	obj = NULL;	ctx = xmlXPathNewContext(doc);	if (!ctx)		goto out;	obj = xmlXPathEvalExpression("//span[@class='keyword']", ctx);	if (!obj)		goto out;	nodeset = obj->nodesetval;	tmp_str = xmlNodeGetContent(nodeset->nodeTab[0]->xmlChildrenNode);	g_debug("The word to search %s", tmp_str);	xmlFree(tmp_str);	tmp_str = NULL;	xmlXPathFreeObject(obj);	obj = NULL;	obj = xmlXPathEvalExpression("//ul/li", ctx);	if (!obj)		goto out;	if (xmlXPathNodeSetIsEmpty(obj->nodesetval))	{		g_message("Result value is empty");		goto out;	}	nodeset = obj->nodesetval;	result = g_ptr_array_sized_new(nodeset->nodeNr + 1);	for (i = 0; i < nodeset->nodeNr; ++i)	{		tmp_str = xmlNodeGetContent(nodeset->nodeTab[i]->xmlChildrenNode);		g_ptr_array_add(result, tmp_str);	}	g_ptr_array_add(result, NULL);//.........这里部分代码省略.........
开发者ID:No-name,项目名称:dict,代码行数:101,


示例27: with_words_at_xpath

int with_words_at_xpath(void (*function)(char *[], size_t, xmlNodePtr), xmlDocPtr document, const char * xpath, FILE *logfile, long parameters, long dnm_parameters) {  //create xpath context  xmlXPathContextPtr xpath_context = xmlXPathNewContext(document);  if (xpath_context == NULL) {    fprintf(logfile, "Unable to create xpath context/n");    xmlFreeDoc(document);    return 0;  }  //evaluate xpath  xmlXPathObjectPtr xpath_result = xmlXPathEvalExpression((xmlChar *)xpath,xpath_context);  if ((xpath_result == NULL) || (xpath_result->nodesetval == NULL) || (xpath_result->nodesetval->nodeNr == 0)) { //didn't find anything    // Clean up    if (xpath_result != NULL) {      if (xpath_result->nodesetval != NULL) {        free(xpath_result->nodesetval->nodeTab);        free(xpath_result->nodesetval);      }      xmlFree(xpath_result);    }    //function call should be done anyway    function(NULL, 0, NULL);    return 0;   //return false, stating that no nodes where found  }  //prepare array for words  size_t word_array_allocated = 2048;  char ** word_array = (char **) malloc(word_array_allocated * sizeof(char *));  size_t word_array_index = 0;  //iterate over results  xmlNodeSetPtr nodeset = xpath_result->nodesetval;  int index;  for (index=0; index < nodeset->nodeNr; index++) {    xmlNodePtr current_node = nodeset->nodeTab[index];    // Obtain NLP-friendly plain-text of the paragraph:    dnmPtr current_dnm = create_DNM(current_node, dnm_parameters);    if (current_dnm == NULL) {      fprintf(stderr, "Couldn't create DNM for xpath %s at position %d in document (fatal)/n", xpath, index);      exit(1);    }        //tokenize sentences    char* plaintext = current_dnm->plaintext;    if (strlen(plaintext) < 2) {   //not a real sentence, additionally it would cause errors in tokenizer      free_DNM(current_dnm);      continue;    }    dnmRanges sentences = tokenize_sentences(plaintext);    // tokenize words    int sentence_index = 0;    for (sentence_index = 0; sentence_index < sentences.length; sentence_index++) {      // Obtaining only the content words here      dnmRanges words = tokenize_words(plaintext, sentences.range[sentence_index], 0);      int word_index;      for(word_index=0; word_index<words.length; word_index++) {        char* word_string = plain_range_to_string(plaintext, words.range[word_index]);        if (parameters & WORDS_NORMALIZE_WORDS) {          normalize_word(&word_string);        }        if (parameters & WORDS_STEM_WORDS) {          char* word_stem;          full_morpha_stem(word_string, &word_stem);          free(word_string);          word_string = word_stem;        }        POSSIBLE_RESIZE(word_array, word_array_index, &word_array_allocated, word_array_allocated*2, char *);        word_array[word_array_index++] = word_string;      }      free(words.range);      if (parameters&WORDS_MARK_END_OF_SENTENCE) {        POSSIBLE_RESIZE(word_array, word_array_index, &word_array_allocated, word_array_allocated*2, char *);        word_array[word_array_index++] = strdup("endofsentence");      }    }    free(sentences.range);    free_DNM(current_dnm);    function(word_array, word_array_index, current_node);    //free memory    size_t i = 0;    while (i < word_array_index) free(word_array[i++]);    word_array_index = 0;  }
开发者ID:KWARC,项目名称:deprecated-LLaMaPUn,代码行数:88,


示例28: libvirt_open

int libvirt_open() {	conn = virConnectOpenReadOnly("xen:///");	if(conn == NULL) {	  printf("libvirt connection open error on uri /n"); 	  return 0;	}	int n;	n = virConnectNumOfDomains(conn);	if(n < 0) {		printf("Error reading number of domains /n");		return -1;	}	int i;	int *domids;	domids = malloc(sizeof(int) * n);	if(domids == 0) {		printf("libvirt domain ids malloc failed");		return -1;	}	n = virConnectListDomains(conn, domids, n);	if(n < 0) {		printf("Error reading list of domains /n");		free(domids);		return -1;	}	free_block_devices();	free_interface_devices();	free_domains();	for (i = 0; i < n ; ++i) {		virDomainPtr dom = NULL;		const char *name;		char *xml = NULL;		xmlDocPtr xml_doc = NULL;		xmlXPathContextPtr xpath_ctx = NULL;		xmlXPathObjectPtr xpath_obj = NULL;		int j;		//printf("Publishing Domain Id : %d /n ", domids[i]);		dom = virDomainLookupByID(conn, domids[i]);		if(dom == NULL) {			printf("Domain no longer active or moved away .. /n");		}		name = virDomainGetName(dom);		//printf("Publishing Domain Name : %s /n ", name);		if(name == NULL) {			printf("Domain name not valid .. /n");			goto cont;			}		if(add_domain(dom) < 0) {			printf("libvirt plugin malloc failed .. /n");			goto cont;		}		xml = virDomainGetXMLDesc(dom, 0);		if(!xml) {			printf("Virt domain xml description error ../n");			goto cont;		}		//printf("Publishing XML : /n %s /n ", xml);		xml_doc = xmlReadDoc((xmlChar *) xml, NULL, NULL, XML_PARSE_NONET);		if(xml_doc == NULL) {			printf("XML read doc error ../n");			goto cont;		}		xpath_ctx = xmlXPathNewContext(xml_doc);		xpath_obj = xmlXPathEval((xmlChar *) "/domain/devices/disk/target[@dev]", xpath_ctx);		if(xpath_obj == NULL || xpath_obj->type != XPATH_NODESET || xpath_obj->nodesetval == NULL) {			goto cont;		}		for(j = 0; j < xpath_obj->nodesetval->nodeNr; ++j) {			xmlNodePtr node;			char *path = NULL;			node = xpath_obj->nodesetval->nodeTab[j];			if(!node) continue;			path = (char *) xmlGetProp (node, (xmlChar *) "dev");			if(!path) continue;			add_block_device(dom, path);		}		xmlXPathFreeObject(xpath_obj);		xpath_obj = xmlXPathEval((xmlChar *) "/domain/devices/interface/target[@dev]", xpath_ctx);		if(xpath_obj == NULL || xpath_obj->type != XPATH_NODESET || xpath_obj->nodesetval == NULL) {			goto cont;		}		for(j = 0; j < xpath_obj->nodesetval->nodeNr; ++j) {			xmlNodePtr node;			char *path = NULL;			node = xpath_obj->nodesetval->nodeTab[j];			if(!node) continue;			path = (char *) xmlGetProp(node, (xmlChar *) "dev");			if(!path) continue;			add_interface_device(dom, path);		}//.........这里部分代码省略.........
开发者ID:imaxxs,项目名称:cyton,代码行数:101,


示例29: save_obconf_settings

static void save_obconf_settings (void){	const char *session_name;	char *user_config_file, *c, *font, *fname;	int count;	const gchar *size = NULL, *bold = NULL, *italic = NULL;	// construct the file path	session_name = g_getenv ("DESKTOP_SESSION");	if (!session_name) session_name = DEFAULT_SES;	fname = g_strconcat (g_ascii_strdown (session_name, -1), "-rc.xml", NULL);	user_config_file = g_build_filename (g_get_user_config_dir (), "openbox/", fname, NULL);	g_free (fname);	// set the font description variables for XML from the font name	font = g_strdup (desktop_font);	while ((c = strrchr (font, ' ')))	{		if (!bold && !italic && !size && atoi (c + 1))			size = c + 1;		else if (!bold && !italic && !g_ascii_strcasecmp (c + 1, "italic"))			italic = c + 1;		else if (!bold && !g_ascii_strcasecmp (c + 1, "bold"))			bold = c + 1;		else break;		*c = '/0';	}	if (!bold) bold = "Normal";	if (!italic) italic = "Normal";	// read in data from XML file	xmlInitParser ();	LIBXML_TEST_VERSION	xmlDocPtr xDoc = xmlParseFile (user_config_file);	if (xDoc == NULL)	{		g_free (font);		g_free (user_config_file);		return;	}	xmlXPathContextPtr xpathCtx = xmlXPathNewContext (xDoc);	xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression ((xmlChar *) "/*[local-name()='openbox_config']/*[local-name()='theme']/*[local-name()='font']", xpathCtx);	// update relevant nodes with new values	for (count = 0; count < xpathObj->nodesetval->nodeNr; count++)	{		xmlNode *node = xpathObj->nodesetval->nodeTab[count];		xmlAttr *attr = node->properties;		xmlNode *cur_node = NULL;		for (cur_node = node->children; cur_node; cur_node = cur_node->next)		{			if (cur_node->type == XML_ELEMENT_NODE)			{				if (!strcmp (cur_node->name, "name")) xmlNodeSetContent (cur_node, font);				if (!strcmp (cur_node->name, "size")) xmlNodeSetContent (cur_node, size);				if (!strcmp (cur_node->name, "weight")) xmlNodeSetContent (cur_node, bold);				if (!strcmp (cur_node->name, "slant"))	xmlNodeSetContent (cur_node, italic);			}		}	}	// cleanup XML	xmlXPathFreeObject (xpathObj);	xmlXPathFreeContext (xpathCtx);	xmlSaveFile (user_config_file, xDoc);	xmlFreeDoc (xDoc);	xmlCleanupParser ();	g_free (font);	g_free (user_config_file);}
开发者ID:l10n-tw,项目名称:pipanel,代码行数:72,


示例30: check_themes

static void check_themes (void){	const char *session_name, *ret;	char *user_config_file, *cptr, *nptr, *fname;	GKeyFile *kf;	GError *err;	int count;	orig_lxsession_theme = "";	orig_openbox_theme = "";	// construct the file path for lxsession settings	session_name = g_getenv ("DESKTOP_SESSION");	if (!session_name) session_name = DEFAULT_SES;	user_config_file = g_build_filename (g_get_user_config_dir (), "lxsession/", session_name, "/desktop.conf", NULL);	// read in data from file to a key file structure	kf = g_key_file_new ();	if (g_key_file_load_from_file (kf, user_config_file, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, NULL))	{		// get data from the key file		err = NULL;		ret = g_key_file_get_string (kf, "GTK", "sNet/ThemeName", &err);		if (err == NULL) orig_lxsession_theme = ret;	}	// construct the file path for openbox settings	fname = g_strconcat (g_ascii_strdown (session_name, -1), "-rc.xml", NULL);	user_config_file = g_build_filename (g_get_user_config_dir (), "openbox/", fname, NULL);	g_free (fname);	// read in data from XML file	xmlInitParser ();	LIBXML_TEST_VERSION	xmlDocPtr xDoc = xmlParseFile (user_config_file);	if (xDoc)	{		xmlXPathContextPtr xpathCtx = xmlXPathNewContext (xDoc);		xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression ((xmlChar *) "/*[local-name()='openbox_config']/*[local-name()='theme']", xpathCtx);		// find relevant node and read value		for (count = 0; count < xpathObj->nodesetval->nodeNr; count++)		{			xmlNode *node = xpathObj->nodesetval->nodeTab[count];			xmlAttr *attr = node->properties;			xmlNode *cur_node = NULL;			for (cur_node = node->children; cur_node; cur_node = cur_node->next)			{				if (cur_node->type == XML_ELEMENT_NODE)				{					if (!strcmp (cur_node->name, "name"))						orig_openbox_theme = xmlNodeGetContent (cur_node);				}			}		}		// cleanup XML		xmlXPathFreeObject (xpathObj);		xmlXPathFreeContext (xpathCtx);		xmlSaveFile (user_config_file, xDoc);		xmlFreeDoc (xDoc);		xmlCleanupParser ();	}	g_free (user_config_file);	// set the new themes if needed	if (strcmp ("PiX", orig_lxsession_theme))	{		set_lxsession_theme ("PiX");		if (needs_refresh) system (RELOAD_LXSESSION);	}	if (strcmp ("PiX", orig_openbox_theme))	{		set_openbox_theme ("PiX");		system (RELOAD_OPENBOX);	}}
开发者ID:l10n-tw,项目名称:pipanel,代码行数:78,



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


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