这篇教程C++ xmlXPathFreeContext函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xmlXPathFreeContext函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlXPathFreeContext函数的具体用法?C++ xmlXPathFreeContext怎么用?C++ xmlXPathFreeContext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xmlXPathFreeContext函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: parserDocByKey/*********************************************** * 得到记录的总数及记录集 * * 成功返回记录数及记录集 * * 失败则返回0和NULL * * resultset用完后请手动free * ***********************************************/xmlXPathObjectPtr parserDocByKey(xmlDocPtr doc, byte * keyName, int * num){ *num = 0; xmlXPathContextPtr context; xmlXPathObjectPtr result; xmlNodeSetPtr nodeset; xmlInitParser(); context = xmlXPathNewContext(doc); if(context == NULL) { //xmlFreeDoc(doc); ErrorLog(ERROR, "open doc fail, doc content is empty"); printf("open doc fail, doc content is empty"); return NULL; } result = xmlXPathEvalExpression((const xmlChar *)keyName, context); xmlXPathFreeContext(context); if(result == NULL) { //xmlFreeDoc(doc); ErrorLog(ERROR, "xmlPathEvalExpression return NULL"); printf("xmlPathEvalExpression return NULL"); return NULL; } //print_xpath_nodes(result->nodesetval, stdout); nodeset = result->nodesetval; if(nodeset == NULL) { xmlXPathFreeObject(result); ErrorLog(ERROR, "nodeset is null"); printf("nodeset is null"); return NULL; } if(xmlXPathNodeSetIsEmpty(result->nodesetval)) { xmlXPathFreeObject(result); ErrorLog(ERROR, "nodeset is empty"); printf("nodeset is empty"); return NULL; } *num = nodeset->nodeNr; //xmlXPathFreeObject (result); xmlCleanupParser(); return result;}
开发者ID:cqm0609,项目名称:epay_sdyl,代码行数:55,
示例2: stringxmlXPathObjectPtr 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,
示例3: cx_parse_xmlstatic 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,
示例4: parse_rss_itembool 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,
示例5: xmlSchematronFreeParserCtxt/** * xmlSchematronFreeParserCtxt: * @ctxt: the schema parser context * * Free the resources associated to the schema parser context */voidxmlSchematronFreeParserCtxt(xmlSchematronParserCtxtPtr ctxt){ if (ctxt == NULL) return; if (ctxt->doc != NULL && !ctxt->preserve) xmlFreeDoc(ctxt->doc); if (ctxt->xctxt != NULL) { xmlXPathFreeContext(ctxt->xctxt); } if (ctxt->namespaces != NULL) xmlFree((char **) ctxt->namespaces); xmlDictFree(ctxt->dict); xmlFree(ctxt);}
开发者ID:AllenChanAncA,项目名称:WiEngine,代码行数:21,
示例6: xmlXPathNewContextvoid XaLibDom::AddValueElementByXPath(xmlDocPtr XmlDomDoc, string XPathExpr, string ValueValue){ xmlNodePtr cur; xmlNodePtr OptionsNode; xpathCtx = xmlXPathNewContext(XmlDomDoc); xpathObj = xmlXPathEvalExpression((const xmlChar *)XPathExpr.c_str(), xpathCtx); cur = xpathObj->nodesetval->nodeTab[0]; OptionsNode = xmlNewChild(cur, NULL, (const xmlChar *) "value", (const xmlChar *)ValueValue.c_str()); xmlXPathFreeObject(xpathObj); xmlXPathFreeContext(xpathCtx);};
开发者ID:XAllegro,项目名称:Xaas,代码行数:15,
示例7: getnodesetxmlXPathObjectPtr getnodeset(xmlDocPtr doc, xmlChar *xpath){ xmlXPathContextPtr context; xmlXPathObjectPtr result; context = xmlXPathNewContext(doc); result = xmlXPathEvalExpression(xpath, context); if (xmlXPathNodeSetIsEmpty(result->nodesetval)) { printf("No result/n"); return NULL; } xmlXPathFreeContext(context); return result;}
开发者ID:github188,项目名称:doc-1,代码行数:15,
示例8: flickcurl_collections_getTree/** * flickcurl_collections_getTree: * @fc: flickcurl context * @collection_id: The ID of the collection to fetch a tree for, or zero to fetch the root collection. Defaults to zero. (or NULL) * @user_id: The ID of the account to fetch the collection tree for. Deafults to the calling user. (or NULL) * * Returns a tree (or sub tree) of collections belonging to a given user. * * Implements flickr.collections.getTree (1.12) * * Return value: a collection or NULL on failure **/flickcurl_collection*flickcurl_collections_getTree(flickcurl* fc, const char* collection_id, const char* user_id){ const char* parameters[9][2]; int count = 0; xmlDocPtr doc = NULL; xmlXPathContextPtr xpathCtx = NULL; flickcurl_collection* collection = NULL; if(collection_id) { parameters[count][0] = "collection_id"; parameters[count++][1]= collection_id; } if(user_id) { parameters[count][0] = "user_id"; parameters[count++][1]= user_id; } parameters[count][0] = NULL; if(flickcurl_prepare(fc, "flickr.collections.getTree", 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; } collection = flickcurl_build_collection(fc, xpathCtx, (const xmlChar*)"/rsp/collections/collection"); tidy: if(xpathCtx) xmlXPathFreeContext(xpathCtx); if(fc->failed) collection = NULL; return collection;}
开发者ID:Chaduke,项目名称:bah.mod,代码行数:60,
示例9: cpuTestLoadMultiXMLstatic virCPUDefPtr *cpuTestLoadMultiXML(const char *arch, const char *name, unsigned int *count){ char *xml = NULL; xmlDocPtr doc = NULL; xmlXPathContextPtr ctxt = NULL; xmlNodePtr *nodes = NULL; virCPUDefPtr *cpus = NULL; int n; int i; if (virAsprintf(&xml, "%s/cputestdata/%s-%s.xml", abs_srcdir, arch, name) < 0) goto cleanup; if (!(doc = virXMLParseFileCtxt(xml, &ctxt))) goto error; n = virXPathNodeSet("/cpuTest/cpu", ctxt, &nodes); if (n <= 0 || !(cpus = calloc(n, sizeof(virCPUDefPtr)))) goto error; for (i = 0; i < n; i++) { ctxt->node = nodes[i]; cpus[i] = virCPUDefParseXML(nodes[i], ctxt, VIR_CPU_TYPE_HOST); if (!cpus[i]) goto error; } *count = n;cleanup: free(xml); free(nodes); xmlXPathFreeContext(ctxt); xmlFreeDoc(doc); return cpus;error: if (cpus) { for (i = 0; i < n; i++) virCPUDefFree(cpus[i]); free(cpus); cpus = NULL; } goto cleanup;}
开发者ID:soulxu,项目名称:libvirt-xuhj,代码行数:48,
示例10: flickcurl_photos_geo_correctLocation/** * flickcurl_photos_geo_correctLocation: * @fc: flickcurl context * @photo_id: The ID of the photo whose WOE location is being corrected. * @place_id: A Flickr Places ID (or NULL) * @woe_id: A Where On Earth (WOE) ID (or NULL) * * Correct a photo location. * * You must pass either a valid Places ID in @place_id or a WOE ID in @woe_id. * * Implements flickr.photos.geo.correctLocation (1.8) * * Return value: non-0 on failure **/intflickcurl_photos_geo_correctLocation(flickcurl* fc, const char* photo_id, const char* place_id, int woe_id){ xmlDocPtr doc = NULL; xmlXPathContextPtr xpathCtx = NULL; void* result = NULL; char woe_id_str[10]; flickcurl_init_params(fc, 0); if(!photo_id) return 1; flickcurl_add_param(fc, "photo_id", photo_id); flickcurl_add_param(fc, "place_id", place_id); if(woe_id > 0) { sprintf(woe_id_str, "%d", woe_id); flickcurl_add_param(fc, "woe_id", woe_id_str); } flickcurl_end_params(fc); if(flickcurl_prepare(fc, "flickr.photos.geo.correctLocation")) 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; } result = NULL; /* your code here */ tidy: if(xpathCtx) xmlXPathFreeContext(xpathCtx); if(fc->failed) result = NULL; return (result == NULL);}
开发者ID:Elfy,项目名称:flickcurl,代码行数:63,
示例11: list_dbus_propertiesvoid list_dbus_properties(xmlDocPtr doc, GDBusConnection *bus, const gchar *dest, const gchar *path, gpointer user){ GHashTable *methods = user; xmlXPathContextPtr context; xmlXPathObjectPtr result; xmlNodeSetPtr nodes; context = xmlXPathNewContext(doc); result = xmlXPathEvalExpression("/node/interface/property[@name]", context); xmlXPathFreeContext(context); if (!result) { g_debug("xpath query failed for property declarations"); return; } if (!result->nodesetval) { g_debug("no results for xpath query"); xmlXPathFreeObject(result); return; } nodes = result->nodesetval; for (gint i = 0; i < nodes->nodeNr; i++) { xmlAttrPtr attrib = nodes->nodeTab[i]->properties; gchar *property; // Find the attribute name while (g_strcmp0(attrib->name, "name") != 0) { attrib = attrib->next; g_assert(attrib); } property = g_strdup_printf("p:%s.%s", nodes->nodeTab[i]->parent->properties->children->content, attrib->children->content); if (!g_hash_table_contains(methods, property)) { g_hash_table_add(methods, property); if (check_access_property(bus, dest, path, nodes->nodeTab[i]->parent->properties->children->content, attrib->children->content)) g_print("/t%s %s/n", property, path); } } xmlXPathFreeObject(result); return;}
开发者ID:linux-pentest,项目名称:dbusmap,代码行数:48,
示例12: GDALGMLJP2GenerateMetadataCPLXMLNode* GDALGMLJP2GenerateMetadata( const CPLString& osTemplateFile, const CPLString& osSourceFile){ GByte* pabyStr = nullptr; if( !VSIIngestFile( nullptr, osTemplateFile, &pabyStr, nullptr, -1 ) ) return nullptr; CPLString osTemplate(reinterpret_cast<char *>(pabyStr)); CPLFree(pabyStr); if( !VSIIngestFile( nullptr, osSourceFile, &pabyStr, nullptr, -1 ) ) return nullptr; CPLString osSource(reinterpret_cast<char *>(pabyStr)); CPLFree(pabyStr); xmlDocPtr pDoc = xmlParseDoc( reinterpret_cast<const xmlChar *>(osSource.c_str())); if( pDoc == nullptr ) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot parse %s", osSourceFile.c_str()); return nullptr; } xmlXPathContextPtr pXPathCtx = xmlXPathNewContext(pDoc); if( pXPathCtx == nullptr ) { xmlFreeDoc(pDoc); return nullptr; } xmlXPathRegisterFunc(pXPathCtx, reinterpret_cast<const xmlChar *>("if"), GDALGMLJP2XPathIf); xmlXPathRegisterFunc(pXPathCtx, reinterpret_cast<const xmlChar *>("uuid"), GDALGMLJP2XPathUUID); pXPathCtx->error = GDALGMLJP2XPathErrorHandler; GDALGMLJP2RegisterNamespaces(pXPathCtx, xmlDocGetRootElement(pDoc)); CPLString osXMLRes = GDALGMLJP2EvalExpr(osTemplate, pXPathCtx, pDoc); xmlXPathFreeContext(pXPathCtx); xmlFreeDoc(pDoc); return CPLParseXMLString(osXMLRes);}
开发者ID:rouault,项目名称:gdal,代码行数:48,
示例13: list_dbus_methodsvoid list_dbus_methods(xmlDocPtr doc, GDBusConnection *bus, const gchar *dest, const gchar *path, gpointer user){ GHashTable *methods = user; xmlXPathContextPtr context; xmlXPathObjectPtr result; xmlNodeSetPtr nodes; context = xmlXPathNewContext(doc); result = xmlXPathEvalExpression("/node/interface/method[@name]", context); xmlXPathFreeContext(context); if (!result) { g_debug("xpath query failed for method declarations"); return; } if (!result->nodesetval) { g_debug("no results for xpath query"); xmlXPathFreeObject(result); return; } nodes = result->nodesetval; for (gint i = 0; i < nodes->nodeNr; i++) { xmlAttrPtr attrib = nodes->nodeTab[i]->properties; gchar *method; method = g_strdup_printf("m:%s.%s", nodes->nodeTab[i]->parent->properties->children->content, attrib->children->content); if (!g_hash_table_contains(methods, method)) { g_hash_table_add(methods, method); if (check_access_method(bus, dest, path, nodes->nodeTab[i]->parent->properties->children->content, attrib->children->content)) { g_print("/t%s %s/n", method, path); } } } xmlXPathFreeObject(result); return;}
开发者ID:linux-pentest,项目名称:dbusmap,代码行数:47,
示例14: cpuTestLoadMultiXMLstatic virCPUDefPtr *cpuTestLoadMultiXML(const char *arch, const char *name, unsigned int *count){ char *xml = NULL; xmlDocPtr doc = NULL; xmlXPathContextPtr ctxt = NULL; xmlNodePtr *nodes = NULL; virCPUDefPtr *cpus = NULL; int n; size_t i; if (virAsprintf(&xml, "%s/cputestdata/%s-%s.xml", abs_srcdir, arch, name) < 0) goto cleanup; if (!(doc = virXMLParseFileCtxt(xml, &ctxt))) goto cleanup; n = virXPathNodeSet("/cpuTest/cpu", ctxt, &nodes); if (n <= 0 || (VIR_ALLOC_N(cpus, n) < 0)) { fprintf(stderr, "/nNo /cpuTest/cpu elements found in %s/n", xml); goto cleanup; } for (i = 0; i < n; i++) { ctxt->node = nodes[i]; cpus[i] = virCPUDefParseXML(nodes[i], ctxt, VIR_CPU_TYPE_HOST); if (!cpus[i]) goto cleanup_cpus; } *count = n; cleanup: VIR_FREE(xml); VIR_FREE(nodes); xmlXPathFreeContext(ctxt); xmlFreeDoc(doc); return cpus; cleanup_cpus: for (i = 0; i < n; i++) virCPUDefFree(cpus[i]); VIR_FREE(cpus); goto cleanup;}
开发者ID:candhare,项目名称:libvirt,代码行数:47,
示例15: 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,
示例16: google_searchgoogle_search_t * google_search(char *keywords) { curl_data_t *curl; google_search_t *search; xmlDoc *doc = NULL; xmlXPathContext *ctx = NULL; xmlXPathObject *xpathObj = NULL; xmlNode *node = NULL; char url[2048]; int i; curl = curl_data_new(); snprintf(url, sizeof(url), "%s%s", baseurlen, space_encode(keywords)); if(curl_download_text(url, curl)) return NULL; doc = (xmlDoc *) htmlReadMemory(curl->data, strlen(curl->data), "/", "utf-8", HTML_PARSE_NOERROR); /* creating xpath request */ ctx = xmlXPathNewContext(doc); xpathObj = xmlXPathEvalExpression((const xmlChar *) "//li/div/h3/a", ctx); search = (google_search_t *) calloc(1, sizeof(google_search_t)); if(!xmlXPathNodeSetIsEmpty(xpathObj->nodesetval)) { search->length = xpathObj->nodesetval->nodeNr; search->result = (google_result_t *) calloc(1, sizeof(google_result_t) * search->length); for(i = 0; i < xpathObj->nodesetval->nodeNr; i++) { node = xpathObj->nodesetval->nodeTab[i]; if(xmlNodeGetContent(node)) search->result[i].title = strdup((char *) xmlNodeGetContent(node)); if(xmlGetProp(node, (unsigned char *) "href")) search->result[i].url = strdup((char *) xmlGetProp(node, (unsigned char *) "href")); } } xmlXPathFreeObject(xpathObj); xmlXPathFreeContext(ctx); xmlFreeDoc(doc); curl_data_free(curl); return search;}
开发者ID:maxux,项目名称:z03,代码行数:47,
示例17: convert_selectstatic int convert_select(void *vinfo, WRBUF record, WRBUF wr_error){ int ret = 0; struct select_info *info = vinfo; xmlDocPtr doc = xmlParseMemory(wrbuf_buf(record), wrbuf_len(record)); if (!doc) { wrbuf_printf(wr_error, "xmlParseMemory failed"); ret = -1; } else { xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc); if (xpathCtx && info->xpath_expr) { xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression((const xmlChar *) info->xpath_expr, xpathCtx); if (xpathObj) { xmlNodeSetPtr nodes = xpathObj->nodesetval; if (nodes) { int i; if (nodes->nodeNr > 0) wrbuf_rewind(record); for (i = 0; i < nodes->nodeNr; i++) { xmlNode *ptr = nodes->nodeTab[i]; if (ptr->type == XML_ELEMENT_NODE) ptr = ptr->children; for (; ptr; ptr = ptr->next) if (ptr->type == XML_TEXT_NODE) wrbuf_puts(record, (const char *) ptr->content); } } xmlXPathFreeObject(xpathObj); } xmlXPathFreeContext(xpathCtx); } xmlFreeDoc(doc); } return ret;}
开发者ID:dcrossleyau,项目名称:yaz,代码行数:46,
示例18: flickcurl_photos_geo_getPerms/** * flickcurl_photos_geo_getPerms: * @fc: flickcurl context * @photo_id: The id of the photo to get permissions for. * * Get permissions for who may view geo data for a photo. * * Implements flickr.photos.geo.getPerms (0.12) * * Return value: non-0 on failure **/flickcurl_perms*flickcurl_photos_geo_getPerms(flickcurl* fc, const char* photo_id){ xmlDocPtr doc = NULL; xmlXPathContextPtr xpathCtx = NULL; flickcurl_perms* perms = NULL; flickcurl_init_params(fc, 0); if(!photo_id) return NULL; flickcurl_add_param(fc, "photo_id", photo_id); flickcurl_end_params(fc); if(flickcurl_prepare(fc, "flickr.photos.geo.getPerms")) 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; } perms = flickcurl_build_perms(fc, xpathCtx, (const xmlChar*)"/rsp/perms"); tidy: if(xpathCtx) xmlXPathFreeContext(xpathCtx); if(fc->failed) { if(perms) flickcurl_free_perms(perms); perms = NULL; } return perms;}
开发者ID:Elfy,项目名称:flickcurl,代码行数:57,
示例19: flickcurl_photos_geo_setContext/** * flickcurl_photos_geo_setContext: * @fc: flickcurl context * @photo_id: The id of the photo to set context data for. * @context: Context is a numeric value representing the photo's geotagginess beyond latitude and longitude. The current values are: 0: not defined, 1: indoors, 2: outdoors. * * Indicate the state of a photo's geotagginess beyond latitude and longitude. * * Note : photos passed to this method must already be geotagged * using the flickcurl_photos_geo_setLocation() method. * * Implements flickr.photos.geo.setContext (1.8) * * Return value: non-0 on failure **/intflickcurl_photos_geo_setContext(flickcurl* fc, const char* photo_id, int context){ xmlDocPtr doc = NULL; xmlXPathContextPtr xpathCtx = NULL; char context_str[3]; void* result = NULL; flickcurl_init_params(fc, 1); if(!photo_id || context < 0 || context > 2) return 1; flickcurl_add_param(fc, "photo_id", photo_id); sprintf(context_str, "%d", context); flickcurl_add_param(fc, "context", context_str); flickcurl_end_params(fc); if(flickcurl_prepare(fc, "flickr.photos.geo.setContext")) 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; } result = NULL; /* your code here */ tidy: if(xpathCtx) xmlXPathFreeContext(xpathCtx); if(fc->failed) result = NULL; return (result == NULL);}
开发者ID:Elfy,项目名称:flickcurl,代码行数:61,
示例20: findXMLTagsextern void findXMLTags (xmlXPathContext *ctx, xmlNode *root, const tagXpathTableTable *xpathTableTable, const kindOption* const kinds,void *userData){ boolean usedAsEnterPoint = FALSE; xmlDocPtr doc = NULL; if (ctx == NULL) { usedAsEnterPoint = TRUE; findRegexTags (); xmlSetGenericErrorFunc (NULL, suppressWarning); doc = makeXMLDoc (); if (doc == NULL) { verbose ("could not parse %s as a XML file/n", getInputFileName()); return; } ctx = xmlXPathNewContext (doc); if (ctx == NULL) error (FATAL, "failed to make a new xpath context for %s", getInputFileName()); root = xmlDocGetRootElement(doc); if (root == NULL) { verbose ("could not get the root node for %s/n", getInputFileName()); goto out; } } findXMLTagsCore (ctx, root, xpathTableTable, kinds, userData);out: if (usedAsEnterPoint) { xmlXPathFreeContext (ctx); if (doc != getInputFileUserData ()) xmlFreeDoc (doc); }}
开发者ID:Sirlsliang,项目名称:ctags,代码行数:46,
示例21: flickcurl_collections_getInfo/** * flickcurl_collections_getInfo: * @fc: flickcurl context * @collection_id: The ID of the collection to fetch information for. * * Returns information for a single collection. Currently can only * be called by the collection owner, this may change. * * Implements flickr.collections.getInfo (1.12) * * Return value: a collection or NULL on failure **/flickcurl_collection*flickcurl_collections_getInfo(flickcurl* fc, const char* collection_id){ xmlDocPtr doc = NULL; xmlXPathContextPtr xpathCtx = NULL; flickcurl_collection* collection = NULL; flickcurl_init_params(fc, 0); if(!collection_id) return NULL; flickcurl_add_param(fc, "collection_id", collection_id); flickcurl_end_params(fc); if(flickcurl_prepare(fc, "flickr.collections.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; } collection = flickcurl_build_collection(fc, xpathCtx, (const xmlChar*)"/rsp/collection"); tidy: if(xpathCtx) xmlXPathFreeContext(xpathCtx); if(fc->failed) { if(collection) flickcurl_free_collection(collection); collection = NULL; } return collection;}
开发者ID:Elfy,项目名称:flickcurl,代码行数:58,
示例22: rn_xml_endvoidrn_xml_end(){ if(ctxt) xmlXPathFreeContext(ctxt); if(document_network) xmlFreeDoc(document_network); if(document_links) xmlFreeDoc(document_links); if(document_model) xmlFreeDoc(document_model); xmlCleanupParser();}
开发者ID:chleemobile,项目名称:rossnet,代码行数:17,
示例23: get_videostatic GHashTable *get_video (xmlNodePtr node){ gint i; gint array_length; xmlXPathContextPtr context; gchar *video_id; GHashTable *video = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); /* Adds the video node's properties */ add_node (node, video); context = xmlXPathNewContext (node->doc); video_id = (gchar *) xmlGetProp (node, (xmlChar *) "id"); array_length = G_N_ELEMENTS (video_info); for (i = 0; i < array_length; i++) { /* Look for the wanted information only under the current video */ gchar *xpath_name = g_strdup_printf ("//video[@id=%s]//%s", video_id, video_info[i].name); xmlNodePtr info_node = xpath_get_node (context, xpath_name); if (info_node) { if (video_info[i].type == EXTENDED) { add_node (info_node, video); } else { g_hash_table_insert (video, g_strdup ((const gchar *) info_node->name), (gchar *) xmlNodeGetContent (info_node)); } } g_free (xpath_name); } g_free (video_id); xmlXPathFreeContext (context); return video;}
开发者ID:GNOME,项目名称:grilo-plugins,代码行数:46,
示例24: obtenir_premier_produit/** * Retourne le premier produit du catalogue (sinon NULL) **/xmlNodePtr obtenir_premier_produit(xmlDocPtr doc) { xmlXPathContextPtr ctxt; xmlXPathObjectPtr xpathRes; xmlNodePtr n = NULL; xmlXPathInit(); if (NULL != (ctxt = xmlXPathNewContext(doc))) { xpathRes = xmlXPathEvalExpression(BAD_CAST "/catalogue/produit[position()=1]", ctxt); if (xpathRes && XPATH_NODESET == xpathRes->type && xpathRes->nodesetval->nodeNr == 1) { n = xpathRes->nodesetval->nodeTab[0]; } xmlXPathFreeObject(xpathRes); xmlXPathFreeContext(ctxt); } return n;}
开发者ID:julp,项目名称:libxml2-examples,代码行数:20,
示例25: subdesc_ana_root/***************************************************************************** 函 数 名 : subdesc_ana_root 功能描述 : 分析根元素 输入参数 : doc xml文档 输出参数 : root 保存数据 返 回 值 : ERR_SUCCESS成功 其他失败 调用函数 : 被调函数 : ============================================================================ 修改历史 : 1.日 期 : 2008年8月26日 修改内容 : 新生成函数*****************************************************************************/static int subdesc_ana_root(xmlDocPtr doc, SUB_ROOT * root){ int i; xmlXPathContextPtr xpathCtx; static SD_ANA g_ana_root[] = { /*xpath cbfunc data offset */ {"/submit/pre_treatment", subdesc_ana_pre_treatment, SUB_STRUCT_OFF(SUB_ROOT,pre_treatment)}, {"/submit/action_list", subdesc_ana_all_action, SUB_STRUCT_OFF(SUB_ROOT,action_list)}, {"/submit/function_list", subdesc_ana_all_function, SUB_STRUCT_OFF(SUB_ROOT,function_list)}, {"/submit/config_item_list", subdesc_ana_all_parameter, SUB_STRUCT_OFF(SUB_ROOT,config_item_list)}, {"/submit/execution_list", subdesc_ana_all_clue, SUB_STRUCT_OFF(SUB_ROOT,execution_list)}, {"/submit/result", subdesc_ana_other, SUB_STRUCT_OFF(SUB_ROOT,result)}, }; static int g_ana_root_len = sizeof(g_ana_root)/sizeof(SD_ANA); /* Create xpath evaluation context */ xpathCtx = xmlXPathNewContext(doc); if(xpathCtx == NULL) { return ERROR_SYSTEM; } /*通过xpath查找相应的元素,使用回调函数进行解析*/ for(i=0;i<g_ana_root_len;i++) { xmlXPathObjectPtr xpathObj; /* Evaluate xpath expression */ xpathObj = xmlXPathEvalExpression((unsigned char*)g_ana_root[i].xpath, xpathCtx); if(xpathObj == NULL) { continue; } (void)g_ana_root[i].cbfunc(xpathObj->nodesetval, (void *)((unsigned long)root+(unsigned long)(g_ana_root[i].dataoff)), root); xmlXPathFreeObject(xpathObj); } xmlXPathFreeContext(xpathCtx); return ERROR_SUCCESS;}
开发者ID:millken,项目名称:zhuxianB30,代码行数:61,
示例26: parse_forecast_xmlstatic 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,
示例27: xmlXPathNewContextbool OSConfigure::saveonestring( std::string path, std::string value ){ 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 false; if ( xmlXPathNodeSetIsEmpty ( result->nodesetval ) ) { return false; } nodeset = result->nodesetval; int size; int i; size = ( nodeset ) ? nodeset->nodeNr : 0; for ( i = size - 1; i >= 0; i-- ) { xmlNodeSetContent ( nodeset->nodeTab[ i ], ( xmlChar * ) value.c_str () ); if ( nodeset->nodeTab[ i ] ->type != XML_NAMESPACE_DECL ) { nodeset->nodeTab[ i ] = NULL; } } xmlXPathFreeObject ( result ); return true;}
开发者ID:BackupTheBerlios,项目名称:openspace-svn,代码行数:45,
示例28: flickcurl_photosets_comments_addComment/** * flickcurl_photosets_comments_addComment: * @fc: flickcurl context * @photoset_id: The id of the photoset to add a comment to. * @comment_text: Text of the comment * * Add a comment to a photoset. * * Implements flickr.photosets.comments.addComment (0.10) * * Return value: new comment ID or non-NULL on failure **/char*flickcurl_photosets_comments_addComment(flickcurl* fc, const char* photoset_id, const char* comment_text){ xmlDocPtr doc = NULL; xmlXPathContextPtr xpathCtx = NULL; char* id = NULL; flickcurl_init_params(fc, 1); if(!photoset_id || !comment_text) return NULL; flickcurl_add_param(fc, "photoset_id", photoset_id); flickcurl_add_param(fc, "comment_text", comment_text); flickcurl_end_params(fc); if(flickcurl_prepare(fc, "flickr.photosets.comments.addComment")) 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; } id = flickcurl_xpath_eval(fc, xpathCtx, (const xmlChar*)"/rsp/comment/@id"); tidy: if(xpathCtx) xmlXPathFreeContext(xpathCtx); if(fc->failed) id = NULL; return id;}
开发者ID:Web5design,项目名称:flickcurl,代码行数:57,
示例29: PHP_METHOD/* {{{ proto void DOMXPath::__construct(DOMDocument doc) U */PHP_METHOD(domxpath, __construct){ zval *id, *doc; xmlDocPtr docp = NULL; dom_object *docobj; dom_xpath_object *intern; xmlXPathContextPtr ctx, oldctx; zend_error_handling error_handling; zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC); if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &id, dom_xpath_class_entry, &doc, dom_document_class_entry) == FAILURE) { zend_restore_error_handling(&error_handling TSRMLS_CC); return; } zend_restore_error_handling(&error_handling TSRMLS_CC); DOM_GET_OBJ(docp, doc, xmlDocPtr, docobj); ctx = xmlXPathNewContext(docp); if (ctx == NULL) { php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC); RETURN_FALSE; } intern = (dom_xpath_object *)zend_object_store_get_object(id TSRMLS_CC); if (intern != NULL) { oldctx = (xmlXPathContextPtr)intern->ptr; if (oldctx != NULL) { php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC); xmlXPathFreeContext(oldctx); } xmlXPathRegisterFuncNS (ctx, (const xmlChar *) "functionString", (const xmlChar *) "http://php.net/xpath", dom_xpath_ext_function_string_php); xmlXPathRegisterFuncNS (ctx, (const xmlChar *) "function", (const xmlChar *) "http://php.net/xpath", dom_xpath_ext_function_object_php); intern->ptr = ctx; ctx->userData = (void *)intern; intern->document = docobj->document; php_libxml_increment_doc_ref((php_libxml_node_object *)intern, docp TSRMLS_CC); }}
开发者ID:AzerTyQsdF,项目名称:osx,代码行数:46,
注:本文中的xmlXPathFreeContext函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ xmlXPathFreeObject函数代码示例 C++ xmlXPathEvalExpression函数代码示例 |