这篇教程C++ xmlDocGetRootElement函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xmlDocGetRootElement函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlDocGetRootElement函数的具体用法?C++ xmlDocGetRootElement怎么用?C++ xmlDocGetRootElement使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xmlDocGetRootElement函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: bzrtp_getPeerAssociatedSecretsHash/** * @brief Parse the cache to find secrets associated to the given ZID, set them and their length in the context if they are found * * @param[in/out] context the current context, used to get the negotiated Hash algorithm and cache access functions and store result * @param[in] peerZID a byte array of the peer ZID * * return 0 on succes, error code otherwise */int bzrtp_getPeerAssociatedSecretsHash(bzrtpContext_t *context, uint8_t peerZID[12]) { if (context == NULL) { return ZRTP_ZIDCACHE_INVALID_CONTEXT; } /* resert cached secret buffer */ free(context->cachedSecret.rs1); free(context->cachedSecret.rs2); free(context->cachedSecret.pbxsecret); free(context->cachedSecret.auxsecret); context->cachedSecret.rs1 = NULL; context->cachedSecret.rs1Length = 0; context->cachedSecret.rs2 = NULL; context->cachedSecret.rs2Length = 0; context->cachedSecret.pbxsecret = NULL; context->cachedSecret.pbxsecretLength = 0; context->cachedSecret.auxsecret = NULL; context->cachedSecret.auxsecretLength = 0; context->cachedSecret.previouslyVerifiedSas = 0; /* parse the cache to find the peer element matching the given ZID */ if (context->cacheBuffer != NULL ) { /* there is a cache, try to find our peer element */ uint8_t peerZidHex[24]; xmlNodePtr cur; bzrtp_int8ToStr(peerZidHex, peerZID, 12); /* compute the peerZID as an Hexa string */ cur = xmlDocGetRootElement(context->cacheBuffer); /* if we found a root element, parse its children node */ if (cur!=NULL) { cur = cur->xmlChildrenNode; } while (cur!=NULL) { if ((!xmlStrcmp(cur->name, (const xmlChar *)"peer"))){ /* found a peer, check his ZID element */ xmlChar *currentZidHex = xmlNodeListGetString(context->cacheBuffer, cur->xmlChildrenNode->xmlChildrenNode, 1); /* ZID is the first element of peer */ if (memcmp(currentZidHex, peerZidHex, 24) == 0) { /* we found the peer element we are looking for */ xmlNodePtr peerNode = cur->xmlChildrenNode->next; /* no need to parse the first child as it is the ZID node */ while (peerNode != NULL) { /* get all the needed information : rs1, rs2, pbx and aux if we found them */ xmlChar *nodeContent = NULL; if (!xmlStrcmp(peerNode->name, (const xmlChar *)"rs1")) { nodeContent = xmlNodeListGetString(context->cacheBuffer, peerNode->xmlChildrenNode, 1); context->cachedSecret.rs1 = (uint8_t *)malloc(RETAINED_SECRET_LENGTH); context->cachedSecret.rs1Length = RETAINED_SECRET_LENGTH; bzrtp_strToUint8(context->cachedSecret.rs1, nodeContent, 2*RETAINED_SECRET_LENGTH); /* RETAINED_SECRET_LENGTH is in byte, the nodeContent buffer is in hexa string so twice the length of byte string */ } if (!xmlStrcmp(peerNode->name, (const xmlChar *)"rs2")) { nodeContent = xmlNodeListGetString(context->cacheBuffer, peerNode->xmlChildrenNode, 1); context->cachedSecret.rs2 = (uint8_t *)malloc(RETAINED_SECRET_LENGTH); context->cachedSecret.rs2Length = RETAINED_SECRET_LENGTH; bzrtp_strToUint8(context->cachedSecret.rs2, nodeContent, 2*RETAINED_SECRET_LENGTH); /* RETAINED_SECRET_LENGTH is in byte, the nodeContent buffer is in hexa string so twice the length of byte string */ } if (!xmlStrcmp(peerNode->name, (const xmlChar *)"aux")) { nodeContent = xmlNodeListGetString(context->cacheBuffer, peerNode->xmlChildrenNode, 1); context->cachedSecret.auxsecretLength = strlen((const char *)nodeContent)/2; context->cachedSecret.auxsecret = (uint8_t *)malloc(context->cachedSecret.auxsecretLength); /* aux secret is of user defined length, node Content is an hexa string */ bzrtp_strToUint8(context->cachedSecret.auxsecret, nodeContent, 2*context->cachedSecret.auxsecretLength); } if (!xmlStrcmp(peerNode->name, (const xmlChar *)"pbx")) { nodeContent = xmlNodeListGetString(context->cacheBuffer, peerNode->xmlChildrenNode, 1); context->cachedSecret.pbxsecret = (uint8_t *)malloc(RETAINED_SECRET_LENGTH); context->cachedSecret.pbxsecretLength = RETAINED_SECRET_LENGTH; bzrtp_strToUint8(context->cachedSecret.pbxsecret, nodeContent, 2*RETAINED_SECRET_LENGTH); /* RETAINED_SECRET_LENGTH is in byte, the nodeContent buffer is in hexa string so twice the length of byte string */ } if (!xmlStrcmp(peerNode->name, (const xmlChar *)"pvs")) { /* this one is the previously verified sas flag */ nodeContent = xmlNodeListGetString(context->cacheBuffer, peerNode->xmlChildrenNode, 1); if (nodeContent[1] == *"1") { /* pvs is a boolean but is stored as a byte, on 2 hex chars */ context->cachedSecret.previouslyVerifiedSas = 1; } } xmlFree(nodeContent); peerNode = peerNode->next; } xmlFree(currentZidHex); currentZidHex=NULL; break; } xmlFree(currentZidHex); currentZidHex=NULL; } cur = cur->next; } } return 0;}
开发者ID:ayham-hassan,项目名称:bzrtp,代码行数:94,
示例2: verify_request/** * verify_request: * @mng: the keys manager * * Verifies XML signature in the request (stdin). * * Returns 0 on success or a negative value if an error occurs. */int verify_request(xmlSecKeysMngrPtr mngr) { xmlBufferPtr buffer = NULL; char buf[256]; xmlDocPtr doc = NULL; xmlNodePtr node = NULL; xmlSecDSigCtxPtr dsigCtx = NULL; int ret; int res = -1; assert(mngr); /* load request in the buffer */ buffer = xmlBufferCreate(); if(buffer == NULL) { fprintf(stdout,"Error: failed to create buffer/n"); goto done; } while(!feof(stdin)) { ret = fread(buf, 1, sizeof(buf), stdin); if(ret < 0) { fprintf(stdout,"Error: read failed/n"); goto done; } xmlBufferAdd(buffer, buf, ret); } /* is the document subbmitted from the form? */ if(strncmp((char*)xmlBufferContent(buffer), "_xmldoc=", 8) == 0) { xmlBufferShrink(buffer, 8); buffer->use = url_decode((char*)xmlBufferContent(buffer), xmlBufferLength(buffer)); } /** * Load doc */ doc = xmlReadMemory(xmlBufferContent(buffer), xmlBufferLength(buffer), NULL, NULL, XML_PARSE_NOENT | XML_PARSE_NOCDATA | XML_PARSE_PEDANTIC | XML_PARSE_NOCDATA); if (doc == NULL) { fprintf(stdout, "Error: unable to parse xml document (syntax error)/n"); goto done; } /* * Check the document is of the right kind */ if(xmlDocGetRootElement(doc) == NULL) { fprintf(stdout,"Error: empty document/n"); goto done; } /* find start node */ node = xmlSecFindNode(xmlDocGetRootElement(doc), xmlSecNodeSignature, xmlSecDSigNs); if(node == NULL) { fprintf(stdout, "Error: start <dsig:Signature/> node not found/n"); goto done; } /* create signature context */ dsigCtx = xmlSecDSigCtxCreate(mngr); if(dsigCtx == NULL) { fprintf(stdout,"Error: failed to create signature context/n"); goto done; } /* we would like to store and print out everything */ /* actually we would not because it opens a security hole dsigCtx->flags = XMLSEC_DSIG_FLAGS_STORE_SIGNEDINFO_REFERENCES | XMLSEC_DSIG_FLAGS_STORE_MANIFEST_REFERENCES | XMLSEC_DSIG_FLAGS_STORE_SIGNATURE; */ /* Verify signature */ if(xmlSecDSigCtxVerify(dsigCtx, node) < 0) { fprintf(stdout,"Error: signature verification failed/n"); goto done; } /* print verification result to stdout */ if(dsigCtx->status == xmlSecDSigStatusSucceeded) { fprintf(stdout, "RESULT: Signature is OK/n"); } else { fprintf(stdout, "RESULT: Signature is INVALID/n"); } fprintf(stdout, "---------------------------------------------------/n"); xmlSecDSigCtxDebugDump(dsigCtx, stdout); /* success */ res = 0;//.........这里部分代码省略.........
开发者ID:KonstantinDavidov,项目名称:xmlsec,代码行数:101,
示例3: rs_profile_camera_findgchar *rs_profile_camera_find(const gchar *make, const gchar *model){ static gchar *last_make = NULL; static gchar *last_model = NULL; static gchar *last_id = NULL; if (NULL == make || NULL == model) return NULL; if (last_make && last_model) { if (g_str_equal(make, last_make) && g_str_equal(model, last_model)) return last_id ? g_strdup(last_id) : NULL; g_free(last_make); g_free(last_model); if (last_id) g_free(last_id); last_make = g_strdup(make); last_model = g_strdup(model); last_id = NULL; } static gchar *filename = NULL; xmlDocPtr doc; xmlNodePtr cur; xmlNodePtr camera = NULL; xmlNodePtr exif = NULL; xmlChar *xml_unique_id, *xml_make, *xml_model; if (!filename) filename = g_build_filename(rs_confdir_get(), G_DIR_SEPARATOR_S, "profiles" G_DIR_SEPARATOR_S "rawstudio-cameras.xml", NULL); if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { g_free(filename); filename = NULL; } if (!filename) filename = g_build_filename(PACKAGE_DATA_DIR, PACKAGE, "profiles" G_DIR_SEPARATOR_S "rawstudio-cameras.xml", NULL); if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) return NULL; doc = xmlParseFile(filename); if (!doc) return NULL; cur = xmlDocGetRootElement(doc); camera = cur->xmlChildrenNode; while(camera) { if (!xmlStrcmp(camera->name, BAD_CAST "camera")) { xml_unique_id = xmlGetProp(camera, BAD_CAST "unique_id"); exif = camera->xmlChildrenNode; while(exif) { if (!xmlStrcmp(exif->name, BAD_CAST "exif")) { xml_make = xmlGetProp(exif, BAD_CAST "make"); if (g_strcmp0((gchar *) xml_make, make) == 0) { xml_model = xmlGetProp(exif, BAD_CAST "model"); if (g_strcmp0((gchar *) xml_model, model) == 0) { xmlFree(xml_make); xmlFree(xml_model); gchar *unique_id = g_strdup((gchar *) xml_unique_id); xmlFree(xml_unique_id); xmlFree(doc); last_id = g_strdup(unique_id); return unique_id; } xmlFree(xml_model); } xmlFree(xml_make); } exif = exif->next; } xmlFree(xml_unique_id); } camera = camera->next; } xmlFree(doc); g_warning("Could not find unique camera: Make:'%s'. Model:'%s'", make, model); return NULL;}
开发者ID:bgromov,项目名称:rawstudio,代码行数:93,
示例4: php_xpath_evalstatic void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */{ zval *id, retval, *context = NULL; xmlXPathContextPtr ctxp; xmlNodePtr nodep = NULL; xmlXPathObjectPtr xpathobjp; size_t expr_len, nsnbr = 0, xpath_type; dom_xpath_object *intern; dom_object *nodeobj; char *expr; xmlDoc *docp = NULL; xmlNsPtr *ns = NULL; zend_bool register_node_ns = 1; if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|O!b", &id, dom_xpath_class_entry, &expr, &expr_len, &context, dom_node_class_entry, ®ister_node_ns) == FAILURE) { return; } intern = Z_XPATHOBJ_P(id); ctxp = (xmlXPathContextPtr) intern->dom.ptr; if (ctxp == NULL) { php_error_docref(NULL, E_WARNING, "Invalid XPath Context"); RETURN_FALSE; } docp = (xmlDocPtr) ctxp->doc; if (docp == NULL) { php_error_docref(NULL, E_WARNING, "Invalid XPath Document Pointer"); RETURN_FALSE; } if (context != NULL) { DOM_GET_OBJ(nodep, context, xmlNodePtr, nodeobj); } if (!nodep) { nodep = xmlDocGetRootElement(docp); } if (nodep && docp != nodep->doc) { php_error_docref(NULL, E_WARNING, "Node From Wrong Document"); RETURN_FALSE; } ctxp->node = nodep; if (register_node_ns) { /* Register namespaces in the node */ ns = xmlGetNsList(docp, nodep); if (ns != NULL) { while (ns[nsnbr] != NULL) nsnbr++; } } ctxp->namespaces = ns; ctxp->nsNr = nsnbr; xpathobjp = xmlXPathEvalExpression((xmlChar *) expr, ctxp); ctxp->node = NULL; if (ns != NULL) { xmlFree(ns); ctxp->namespaces = NULL; ctxp->nsNr = 0; } if (! xpathobjp) { RETURN_FALSE; } if (type == PHP_DOM_XPATH_QUERY) { xpath_type = XPATH_NODESET; } else { xpath_type = xpathobjp->type; } switch (xpath_type) { case XPATH_NODESET: { int i; xmlNodeSetPtr nodesetp; array_init(&retval); if (xpathobjp->type == XPATH_NODESET && NULL != (nodesetp = xpathobjp->nodesetval)) { for (i = 0; i < nodesetp->nodeNr; i++) { xmlNodePtr node = nodesetp->nodeTab[i]; zval child; if (node->type == XML_NAMESPACE_DECL) { xmlNsPtr curns; xmlNodePtr nsparent; nsparent = node->_private;//.........这里部分代码省略.........
开发者ID:AmesianX,项目名称:php-src,代码行数:101,
示例5: parse_msg/** * Parse incoming message, send all data to msg * @param msg domain model msg * @param ibuf input buffer * @param ilen input buffer len * @return SUCCEED/FAIL */int parse_msg(Message_t *msg, char *ibuf, long ilen){ int ret = SUCCEED; msgbuilder_t *descr; char *buf; short *p_short; long *p_long; char *cp; void *fld_ptr; char *p_string_el; xmlDocPtr doc; xmlNodePtr rootNode; xmlNode *currentNode = NULL; short item; /* start libxml2 XML doc */ doc = xmlReadMemory( ibuf, strlen(ibuf), NULL, NULL, 0 ); if ( NULL == doc ) { TP_LOG(log_error, "Failed to read XML document!"); return FAIL; } rootNode = xmlDocGetRootElement( doc ); currentNode = rootNode->children; /* loop over all tags */ for (; currentNode; currentNode = currentNode->next ) { /* find tag descriptor */ if (NULL==(descr = get_tag((char *)currentNode->name))) { TP_LOG(log_error, "Failed to get tag descr for [%s]", currentNode->name); ret = FAIL; goto out; } /* get the content of the tag */ if (NULL==(buf = (char *)xmlNodeGetContent(currentNode))) { TP_LOG(log_error, "NULL tag: [%s]", currentNode->name); ret = FAIL; goto out; } TP_LOG(log_debug, "got tag [%s] value [%s]", currentNode->name, buf?buf:"(null)"); /* load the field into struct accordingly */ fld_ptr = (char *)msg + descr->msgoffs + descr->elmoffs; switch (descr->elmtyp) { case MSG_SHORT: p_short = (short *)fld_ptr; *p_short = atoi(buf); break; case MSG_LONG: p_long = (long *)fld_ptr; *p_long = atol(buf); break; case MSG_STRING: strcpy((char *)fld_ptr, buf); break; case MSG_ARRAY_SHORT: /* get item number from tag */ cp = strchr(currentNode->name, '_'); cp++; item = atoi(cp); p_short = (short *)( (char *)fld_ptr + item*sizeof(short)); *p_short = atoi(buf); break; case MSG_ARRAY_STRING: /* get item number from tag */ cp = strchr(currentNode->name, '_'); cp++; item = atoi(cp); p_string_el = ( (char *)fld_ptr + item*MAX_STR); strcpy(p_string_el, buf); //.........这里部分代码省略.........
开发者ID:eleckis,项目名称:fmtbenchmarks,代码行数:101,
示例6: ddcci_create_db_protected/* recursionlevel: Protection against looping includes * default_caps: CAPS passed to ddcci_create_db (read from the monitor) * prof_caps: CAPS read from one of the profile (NULL if none has been read yet) */int ddcci_create_db_protected( struct monitor_db* mon_db, const char* pnpname, struct caps* caps, int recursionlevel, char* defined, int faulttolerance){ xmlDocPtr mon_doc; xmlNodePtr root, mon_child, mon_control; xmlChar *tmp; char buffer[256]; if (options_doc == NULL) { fprintf(stderr, _("Database must be inited before reading a monitor file./n")); return 0; } snprintf(buffer, 256, "%s/monitor/%s.xml", datadir, pnpname); mon_doc = xmlParseFile(buffer); if (mon_doc == NULL) { fprintf(stderr, _("Document not parsed successfully./n")); return 0; } root = xmlDocGetRootElement(mon_doc); if (root == NULL) { fprintf(stderr, _("empty monitor/%s.xml/n"), pnpname); xmlFreeDoc(mon_doc); return 0; } if (xmlStrcmp(root->name, (const xmlChar *) "monitor")) { fprintf(stderr, _("monitor/%s.xml of the wrong type, root node %s != monitor"), pnpname, root->name); xmlFreeDoc(mon_doc); return 0; } if (!mon_db->name) { mon_db->name = xmlGetProp(root, BAD_CAST "name"); DDCCI_DB_RETURN_IF(mon_db->name == NULL, 0, _("Can't find name property."), root); } if ((mon_db->init == unknown) && (tmp = xmlGetProp(root, BAD_CAST "init"))) { if (!(xmlStrcmp(tmp, (const xmlChar *)"standard"))) { mon_db->init = standard; } else if (!(xmlStrcmp(tmp, (const xmlChar *)"samsung"))) { mon_db->init = samsung; } else { DDCCI_DB_RETURN_IF(1, 0, _("Invalid type."), root); } xmlFree(tmp); } if ((tmp = xmlGetProp(root, BAD_CAST "caps"))) { if (faulttolerance) fprintf(stderr, "Warning: caps property is deprecated./n"); else { fprintf(stderr, "Error: caps property is deprecated./n"); return 0; } } if ((tmp = xmlGetProp(root, BAD_CAST "include"))) { if (faulttolerance) fprintf(stderr, "Warning: include property is deprecated./n"); else { fprintf(stderr, "Error: include property is deprecated./n"); return 0; } } /* Create group-subgroup structure (we'll clean it up later) */ if (!recursionlevel) { /*printf("Creating struct.../n");*/ xmlNodePtr group, subgroup; xmlChar *options_groupname, *options_subgroupname; struct group_db *current_group; struct group_db **last_group_ref = &mon_db->group_list; /* List groups (options.xml) */ for (group = xmlDocGetRootElement(options_doc)->xmlChildrenNode; group != NULL; group = group->next) { options_groupname = NULL; if (xmlStrcmp(group->name, (const xmlChar *) "group")) { // Not a group continue; } *last_group_ref = current_group = malloc(sizeof(struct group_db)); memset(current_group, 0, sizeof(struct group_db)); last_group_ref = ¤t_group->next; /*printf("On group %p/n", current_group);*/ options_groupname = xmlGetProp(group, BAD_CAST "name"); DDCCI_DB_RETURN_IF(options_groupname == NULL, 0, _("Can't find name property."), group); current_group->name = _D((char*)options_groupname); /* Note: copy string, so we can free options_groupname */ xmlFree(options_groupname);//.........这里部分代码省略.........
开发者ID:Whisprin,项目名称:ddccontrol,代码行数:101,
示例7: xmlParseFilebool Vocations::loadFromXml(const std::string& datadir){ std::string filename = datadir + "vocations.xml"; xmlDocPtr doc = xmlParseFile(filename.c_str()); if(doc){ xmlNodePtr root, p; root = xmlDocGetRootElement(doc); if(xmlStrcmp(root->name,(const xmlChar*)"vocations") != 0){ xmlFreeDoc(doc); return false; } p = root->children; while(p){ if(xmlStrcmp(p->name, (const xmlChar*)"vocation") == 0){ std::string str; int intVal; float floatVal; Vocation* voc = NULL; xmlNodePtr skillNode; if(readXMLInteger(p, "id", intVal)){ voc = new Vocation(intVal); if(readXMLString(p, "name", str)){ voc->name = str; } if(readXMLString(p, "description", str)){ voc->description = str; } if(readXMLInteger(p, "gaincap", intVal)){ voc->gainCap = intVal; } if(readXMLInteger(p, "gainhp", intVal)){ voc->gainHP = intVal; } if(readXMLInteger(p, "gainmana", intVal)){ voc->gainMana = intVal; } if(readXMLInteger(p, "gainhpticks", intVal)){ voc->gainHealthTicks = intVal; } if(readXMLInteger(p, "gainhpamount", intVal)){ voc->gainHealthAmount = intVal; } if(readXMLInteger(p, "gainmanaticks", intVal)){ voc->gainManaTicks = intVal; } if(readXMLInteger(p, "gainmanaamount", intVal)){ voc->gainManaAmount = intVal; } if(readXMLInteger(p, "maxsoul", intVal)){ voc->maxSoul = intVal; } if(readXMLInteger(p, "gainsoulticks", intVal)){ voc->gainSoulTicks = intVal; } if(readXMLFloat(p, "manamultiplier", floatVal)){ voc->manaMultiplier = floatVal; } skillNode = p->children; while(skillNode){ if(xmlStrcmp(skillNode->name, (const xmlChar*)"skill") == 0){ SkillType skill_id; try { if(readXMLInteger(skillNode, "id", intVal)){ skill_id = SkillType::fromInteger(intVal); } else if(readXMLString(skillNode, "name", str)){ skill_id = SkillType::fromString(str); } if(readXMLInteger(skillNode, "base", intVal)){ voc->skillBases[skill_id.value()] = intVal; } if(readXMLFloat(skillNode, "multiplier", floatVal)){ voc->skillMultipliers[skill_id.value()] = floatVal; } } catch(enum_conversion_error&){ std::cout << "Missing skill id ." << std::endl; } } else if(xmlStrcmp(skillNode->name, (const xmlChar*)"damage") == 0){ if(readXMLFloat(skillNode, "magicDamage", floatVal)){ voc->magicBaseDamage = floatVal; } if(readXMLFloat(skillNode, "wandDamage", floatVal)){ voc->wandBaseDamage = floatVal; } if(readXMLFloat(skillNode, "healingDamage", floatVal)){ voc->healingBaseDamage = floatVal; } } else if(xmlStrcmp(skillNode->name, (const xmlChar*)"meleeDamage") == 0){ if(readXMLFloat(skillNode, "sword", floatVal)){ voc->swordBaseDamage = floatVal; } if(readXMLFloat(skillNode, "axe", floatVal)){ voc->axeBaseDamage = floatVal; } if(readXMLFloat(skillNode, "club", floatVal)){//.........这里部分代码省略.........
开发者ID:Ablankzin,项目名称:server,代码行数:101,
示例8: g_list_alloc/* parser for the complete xml file */GList *parseDoc (char *docname){ xmlDocPtr doc; xmlNodePtr cur; xmlParserCtxtPtr ctxt; eventlist = g_list_alloc (); /* allocates memory for new list */ if (getValidate() == TRUE) { ctxt = xmlCreateFileParserCtxt(docname); if (ctxt == NULL) { exit (1); } ctxt->validate = 1; /* check the XML's DTD */ xmlParseDocument(ctxt); if (!ctxt->valid) { g_print ("Please correct this problem or grootevent isn't able to run./n" "Hint: You could also disable validating (--help for more infos)/n"); exit (1); } } doc = xmlParseFile (docname); if (doc == NULL) { fprintf (stderr, "Document not parsed successfully. /n"); return NULL; } cur = xmlDocGetRootElement (doc); if (cur == NULL) { fprintf (stderr, "empty document/n"); xmlFreeDoc (doc); return NULL; } if (xmlStrcmp (cur->name, (const xmlChar *) "grootevent")) { fprintf (stderr, "document of the wrong type, root node != grootevent/n"); xmlFreeDoc (doc); return NULL; } cur = cur->xmlChildrenNode; while (cur != NULL) { if ((!xmlStrcmp (cur->name, (const xmlChar *) "eventinfo"))) { parseEventInfo (doc, cur); } cur = cur->next; } xmlFreeDoc (doc); return eventlist;}
开发者ID:BackupTheBerlios,项目名称:grootevent,代码行数:68,
示例9: xmlParseFilebool Vocations::loadFromXml(){ std::string filename = "data/XML/vocations.xml"; xmlDocPtr doc = xmlParseFile(filename.c_str()); if(doc) { xmlNodePtr root, p; root = xmlDocGetRootElement(doc); if(xmlStrcmp(root->name,(const xmlChar*)"vocations") != 0) { xmlFreeDoc(doc); return false; } p = root->children; while(p) { std::string str; int32_t intVal; if(xmlStrcmp(p->name, (const xmlChar*)"vocation") == 0) { Vocation* voc = new Vocation(); uint32_t voc_id; xmlNodePtr configNode; if(readXMLInteger(p, "id", intVal)) { float floatVal; voc_id = intVal; if(readXMLString(p, "name", str)) voc->name = str; if(readXMLInteger(p, "clientid", intVal)) voc->clientId = intVal; if(readXMLString(p, "description", str)) voc->description = str; if(readXMLInteger(p, "gaincap", intVal)) voc->gainCap = intVal; if(readXMLInteger(p, "gainhp", intVal)) voc->gainHP = intVal; if(readXMLInteger(p, "gainmana", intVal)) voc->gainMana = intVal; if(readXMLInteger(p, "gainhpticks", intVal)) voc->gainHealthTicks = intVal; if(readXMLInteger(p, "gainhpamount", intVal)) voc->gainHealthAmount = intVal; if(readXMLInteger(p, "gainmanaticks", intVal)) voc->gainManaTicks = intVal; if(readXMLInteger(p, "gainmanaamount", intVal)) voc->gainManaAmount = intVal; if(readXMLFloat(p, "manamultiplier", floatVal)) voc->manaMultiplier = floatVal; if(readXMLInteger(p, "attackspeed", intVal)) voc->attackSpeed = intVal; if(readXMLInteger(p, "basespeed", intVal)) voc->baseSpeed = intVal; if(readXMLInteger(p, "soulmax", intVal)) voc->soulMax = intVal; if(readXMLInteger(p, "gainsoulticks", intVal)) voc->gainSoulTicks = intVal; if(readXMLInteger(p, "fromvoc", intVal)) voc->fromVocation = intVal; configNode = p->children; while(configNode) { if(xmlStrcmp(configNode->name, (const xmlChar*)"skill") == 0) { uint32_t skill_id; if(readXMLInteger(configNode, "id", intVal)) { skill_id = intVal; if(skill_id > SKILL_LAST) std::cout << "No valid skill id. " << skill_id << std::endl; else { if(readXMLFloat(configNode, "multiplier", floatVal)) voc->skillMultipliers[skill_id] = floatVal; } } else std::cout << "Missing skill id." << std::endl; }//.........这里部分代码省略.........
开发者ID:CkyLua,项目名称:tfs,代码行数:101,
|