这篇教程C++ xmlDocSetRootElement函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xmlDocSetRootElement函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlDocSetRootElement函数的具体用法?C++ xmlDocSetRootElement怎么用?C++ xmlDocSetRootElement使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xmlDocSetRootElement函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: dt_validateHRESULT dt_validate(XDR_DT dt, xmlChar const* content){ xmlDocPtr tmp_doc; xmlNodePtr node; xmlNsPtr ns; HRESULT hr; TRACE("(dt:%s, %s)/n", dt_to_str(dt), wine_dbgstr_a((char const*)content)); if (!datatypes_schema) { xmlSchemaParserCtxtPtr spctx; assert(datatypes_src != NULL); spctx = xmlSchemaNewMemParserCtxt((char const*)datatypes_src, datatypes_len); datatypes_schema = Schema_parse(spctx); xmlSchemaFreeParserCtxt(spctx); } switch (dt) { case DT_INVALID: return E_FAIL; case DT_BIN_BASE64: case DT_BIN_HEX: case DT_BOOLEAN: case DT_CHAR: case DT_DATE: case DT_DATE_TZ: case DT_DATETIME: case DT_DATETIME_TZ: case DT_FIXED_14_4: case DT_FLOAT: case DT_I1: case DT_I2: case DT_I4: case DT_I8: case DT_INT: case DT_NMTOKEN: case DT_NMTOKENS: case DT_NUMBER: case DT_R4: case DT_R8: case DT_STRING: case DT_TIME: case DT_TIME_TZ: case DT_UI1: case DT_UI2: case DT_UI4: case DT_UI8: case DT_URI: case DT_UUID: if (!datatypes_schema) { ERR("failed to load schema for urn:schemas-microsoft-com:datatypes, " "you're probably using an old version of libxml2: " LIBXML_DOTTED_VERSION "/n"); /* Hopefully they don't need much in the way of XDR datatypes support... */ return S_OK; } if (content && xmlStrlen(content)) { tmp_doc = xmlNewDoc(NULL); node = xmlNewChild((xmlNodePtr)tmp_doc, NULL, dt_to_str(dt), content); ns = xmlNewNs(node, DT_nsURI, BAD_CAST "dt"); xmlSetNs(node, ns); xmlDocSetRootElement(tmp_doc, node); hr = Schema_validate_tree(datatypes_schema, (xmlNodePtr)tmp_doc); xmlFreeDoc(tmp_doc); } else { /* probably the node is being created manually and has no content yet */ hr = S_OK; } return hr; default: FIXME("need to handle dt:%s/n", dt_to_str(dt)); return S_OK; }}
开发者ID:aragaer,项目名称:wine,代码行数:81,
示例2: gen_instance_xml//!//! Encodes instance metadata (contained in ncInstance struct) in XML//! and writes it to file instance->xmlFilePath (/path/to/instance/instance.xml)//! That file gets processed through tools/libvirt.xsl (/etc/eucalyptus/libvirt.xsl)//! to produce /path/to/instance/libvirt.xml file that is passed to libvirt create.//!//! @param[in] instance a pointer to the instance to generate XML from//!//! @return EUCA_OK if the operation is successful. Known error code returned include EUCA_ERROR.//!//! @see write_xml_file()//!int gen_instance_xml(const ncInstance * instance){ int ret = EUCA_ERROR; int i = 0; int j = 0; char *path = NULL; char cores_s[10] = ""; char memory_s[10] = ""; char bitness[4] = ""; char root_uuid[64] = ""; char devstr[SMALL_CHAR_BUFFER_SIZE] = ""; xmlNodePtr disk = NULL; xmlDocPtr doc = NULL; xmlNodePtr instanceNode = NULL; xmlNodePtr hypervisor = NULL; xmlNodePtr backing = NULL; xmlNodePtr root = NULL; xmlNodePtr key = NULL; xmlNodePtr os = NULL; xmlNodePtr disks = NULL; xmlNodePtr rootNode = NULL; xmlNodePtr nics = NULL; xmlNodePtr nic = NULL; const virtualBootRecord *vbr = NULL; INIT(); pthread_mutex_lock(&xml_mutex); { doc = xmlNewDoc(BAD_CAST "1.0"); instanceNode = xmlNewNode(NULL, BAD_CAST "instance"); xmlDocSetRootElement(doc, instanceNode); // hypervisor-related specs hypervisor = xmlNewChild(instanceNode, NULL, BAD_CAST "hypervisor", NULL); _ATTRIBUTE(hypervisor, "type", instance->hypervisorType); _ATTRIBUTE(hypervisor, "capability", hypervsorCapabilityTypeNames[instance->hypervisorCapability]); snprintf(bitness, 4, "%d", instance->hypervisorBitness); _ATTRIBUTE(hypervisor, "bitness", bitness); //! backing specification (@todo maybe expand this with device maps or whatnot?) backing = xmlNewChild(instanceNode, NULL, BAD_CAST "backing", NULL); root = xmlNewChild(backing, NULL, BAD_CAST "root", NULL); assert(instance->params.root); _ATTRIBUTE(root, "type", ncResourceTypeName[instance->params.root->type]); _ELEMENT(instanceNode, "name", instance->instanceId); _ELEMENT(instanceNode, "uuid", instance->uuid); _ELEMENT(instanceNode, "reservation", instance->reservationId); _ELEMENT(instanceNode, "user", instance->userId); _ELEMENT(instanceNode, "dnsName", instance->dnsName); _ELEMENT(instanceNode, "privateDnsName", instance->privateDnsName); _ELEMENT(instanceNode, "instancePath", instance->instancePath); if (instance->params.kernel) { path = instance->params.kernel->backingPath; if (path_check(path, "kernel")) goto free; // sanity check _ELEMENT(instanceNode, "kernel", path); } if (instance->params.ramdisk) { path = instance->params.ramdisk->backingPath; if (path_check(path, "ramdisk")) goto free; // sanity check _ELEMENT(instanceNode, "ramdisk", path); } _ELEMENT(instanceNode, "consoleLogPath", instance->consoleFilePath); _ELEMENT(instanceNode, "userData", instance->userData); _ELEMENT(instanceNode, "launchIndex", instance->launchIndex); snprintf(cores_s, sizeof(cores_s), "%d", instance->params.cores); _ELEMENT(instanceNode, "cores", cores_s); snprintf(memory_s, sizeof(memory_s), "%d", instance->params.mem * 1024); _ELEMENT(instanceNode, "memoryKB", memory_s); // SSH-key related key = _NODE(instanceNode, "key"); _ATTRIBUTE(key, "isKeyInjected", _BOOL(instance->do_inject_key)); _ATTRIBUTE(key, "sshKey", instance->keyName); // OS-related specs os = _NODE(instanceNode, "os"); _ATTRIBUTE(os, "platform", instance->platform); _ATTRIBUTE(os, "virtioRoot", _BOOL(config_use_virtio_root)); _ATTRIBUTE(os, "virtioDisk", _BOOL(config_use_virtio_disk)); _ATTRIBUTE(os, "virtioNetwork", _BOOL(config_use_virtio_net));//.........这里部分代码省略.........
开发者ID:NalaGinrut,项目名称:eucalyptus,代码行数:101,
示例3: get_state_data/** * @brief Retrieve state data from device and return them as XML document * * @param model Device data model. libxml2 xmlDocPtr. * @param running Running datastore content. libxml2 xmlDocPtr. * @param[out] err Double pointer to error structure. Fill error when some occurs. * @return State data as libxml2 xmlDocPtr or NULL in case of error. */xmlDocPtr get_state_data (xmlDocPtr model, xmlDocPtr running, struct nc_err **err){ nc_verb_verbose("get_state_data/n"); nc_verb_verbose("erropt=%u/n", erropt); xmlDocPtr state; xmlNodePtr root; xmlNsPtr ns; state = xmlNewDoc(BAD_CAST "1.0"); root = xmlNewDocNode(state, NULL, BAD_CAST "capable-switch", NULL); xmlDocSetRootElement(state, root); ns = xmlNewNs(root, BAD_CAST "urn:onf:of111:config:yang", NULL); xmlSetNs(root, ns); // state that should be queried here // ### base // #/ofc:capable-switch/ofc:config-version xmlNewChild(root, ns, BAD_CAST "config-version", BAD_CAST "1.1.1");// // ### configuration points// // ### Resources// xmlNodePtr resources = xmlNewChild(root, NULL, BAD_CAST "resources", NULL); // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:number // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:current-rate // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:max-rate // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:state // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:state/ofc:oper-state // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:state/ofc:blocked // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:state/ofc:live // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:current // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:current/ofc:rate // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:current/ofc:auto-negotiate // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:current/ofc:medium // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:current/ofc:pause // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:supported // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:supported/ofc:rate // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:supported/ofc:auto-negotiate // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:supported/ofc:medium // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:supported/ofc:pause // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:advertised-peer // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:advertised-peer/ofc:rate // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:advertised-peer/ofc:auto-negotiate // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:advertised-peer/ofc:medium // #/ofc:capable-switch/ofc:resources/ofc:port/ofc:features/ofc:advertised-peer/ofc:pause get_port_info(ofc_state.xmp_client_handle, resources, running); xmlNodePtr lsis = xmlNewChild(root, NULL, BAD_CAST "logical-switches", NULL); // ### LSIs // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:max-buffered-packets // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:max-tables // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:max-ports // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:flow-statistics // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:table-statistics // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:port-statistics // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:group-statistics // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:queue-statistics // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:reassemble-ip-fragments // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:block-looping-ports // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:reserved-port-types // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:reserved-port-types/ofc:type // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:group-types // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:group-types/ofc:type // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:group-capabilities // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:group-capabilities/ofc:capability // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:action-types // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:action-types/ofc:type // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:instruction-types // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:capabilities/ofc:instruction-types/ofc:type // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:controllers/ofc:controller/ofc:state // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:controllers/ofc:controller/ofc:state/ofc:connection-state // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:controllers/ofc:controller/ofc:state/ofc:current-version // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:controllers/ofc:controller/ofc:state/ofc:supported-versions // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:controllers/ofc:controller/ofc:state/ofc:local-ip-address-in-use // #/ofc:capable-switch/ofc:logical-switches/ofc:switch/ofc:controllers/ofc:controller/ofc:state/ofc:local-port-in-use get_lsi_info(ofc_state.xmp_client_handle, lsis, running); return state;}
开发者ID:bisdn,项目名称:of-config,代码行数:90,
示例4: winfo2xmppint winfo2xmpp(str* to_uri, str* body, str* id){ xmlAttrPtr attr= NULL; str xmpp_msg; char* watcher= NULL ; str from_uri = {0, 0}; xmlDocPtr notify_doc= NULL; xmlDocPtr doc= NULL; xmlNodePtr pidf_root= NULL; xmlNodePtr root_node= NULL; xmlNodePtr node= NULL; xmlBufferPtr buffer= NULL; str watcher_str; LM_DBG("start.../n"); notify_doc= xmlParseMemory(body->s, body->len); if(notify_doc== NULL) { LM_ERR("while parsing xml memory/n"); return -1; } pidf_root= XMLDocGetNodeByName(notify_doc, "watcherinfo", NULL); if(pidf_root== NULL) { LM_ERR("while extracting 'presence' node/n"); goto error; } node = XMLNodeGetNodeByName(pidf_root, "watcher", NULL); for (; node!=NULL; node = node->next) { if( xmlStrcasecmp(node->name,(unsigned char*)"watcher")) continue; watcher= (char*)xmlNodeGetContent(node->children); if(watcher== NULL) { LM_ERR("while extracting watcher node content/n"); goto error; } watcher_str.s = watcher; watcher_str.len = strlen(watcher); from_uri.s = xmpp_uri_sip2xmpp(&watcher_str); if(from_uri.s == NULL) { LM_ERR("Failed to transform uri from sip to xmpp/n"); goto error; } from_uri.len = strlen(from_uri.s); xmlFree(watcher); watcher= NULL; doc= xmlNewDoc( 0 ); if(doc== NULL) { LM_ERR("when creating new xml doc/n"); goto error; } root_node = xmlNewNode(NULL, BAD_CAST "presence"); if(root_node== NULL) { LM_ERR("when adding new node/n"); goto error; } xmlDocSetRootElement(doc, root_node); attr= xmlNewProp(root_node, BAD_CAST "to", BAD_CAST to_uri->s); if(attr== NULL) { LM_ERR("while adding attribute to_uri/n"); goto error; } attr= xmlNewProp(root_node, BAD_CAST "from", BAD_CAST from_uri.s); if(attr== NULL) { LM_ERR("while adding attribute from_uri/n"); goto error; } attr= xmlNewProp(root_node, BAD_CAST "type", BAD_CAST "subscribe"); if(attr== NULL) { LM_ERR("while adding attribute type/n"); goto error; } buffer= xmlBufferCreate(); if(buffer== NULL) { LM_ERR("while adding creating new buffer/n"); goto error; } xmpp_msg.len= xmlNodeDump(buffer, doc, root_node, 1,1); if(xmpp_msg.len== -1) { LM_ERR("while dumping node/n"); goto error; } xmpp_msg.s= (char*)xmlBufferContent( buffer);//.........这里部分代码省略.........
开发者ID:Danfx,项目名称:opensips,代码行数:101,
示例5: XOJ_CHECK_TYPEvoid Settings::save(){ XOJ_CHECK_TYPE(Settings); if (this->timeoutId) { g_source_remove(this->timeoutId); this->timeoutId = 0; } xmlDocPtr doc; xmlNodePtr root; xmlNodePtr xmlNode; xmlIndentTreeOutput = TRUE; doc = xmlNewDoc((const xmlChar*) "1.0"); if (doc == NULL) { return; } saveButtonConfig(); /* Create metadata root */ root = xmlNewDocNode(doc, NULL, (const xmlChar*) "settings", NULL); xmlDocSetRootElement(doc, root); xmlNodePtr com = xmlNewComment((const xmlChar*) "The Xournal++ settings file. Do not edit this file! " "The most settings are available in the Settings dialog, " "the others are commented in this file, but handle with care!"); xmlAddPrevSibling(root, com); WRITE_BOOL_PROP(useXinput); WRITE_BOOL_PROP(presureSensitivity); WRITE_BOOL_PROP(ignoreCoreEvents); WRITE_STRING_PROP(selectedToolbar); WRITE_STRING_PROP(lastSavePath); WRITE_STRING_PROP(lastImagePath); WRITE_INT_PROP(displayDpi); WRITE_INT_PROP(mainWndWidth); WRITE_INT_PROP(mainWndHeight); WRITE_BOOL_PROP(maximized); WRITE_BOOL_PROP(showSidebar); WRITE_INT_PROP(sidebarWidth); WRITE_BOOL_PROP(sidebarOnRight); WRITE_BOOL_PROP(scrollbarOnLeft); WRITE_BOOL_PROP(showTwoPages); WRITE_BOOL_PROP(presentationMode); WRITE_STRING_PROP(fullscreenHideElements); WRITE_COMMENT("Which gui elements are hidden if you are in Fullscreen mode, separated by a colon (,)"); WRITE_STRING_PROP(presentationHideElements); WRITE_COMMENT("Which gui elements are hidden if you are in Presentation mode, separated by a colon (,)"); WRITE_BOOL_PROP(showBigCursor); if (this->scrollbarHideType == SCROLLBAR_HIDE_BOTH) { saveProperty((const char*) "scrollbarHideType", "both", root); } else if (this->scrollbarHideType == SCROLLBAR_HIDE_HORIZONTAL) { saveProperty((const char*) "scrollbarHideType", "horizontal", root); } else if (this->scrollbarHideType == SCROLLBAR_HIDE_VERTICAL) { saveProperty((const char*) "scrollbarHideType", "vertical", root); } else { saveProperty((const char*) "scrollbarHideType", "none", root); } WRITE_BOOL_PROP(autoloadPdfXoj); WRITE_COMMENT("Hides scroolbars in the main window, allowed values: /"none/", /"horizontal/", /"vertical/", /"both/""); WRITE_STRING_PROP(defaultSaveName); WRITE_STRING_PROP(visiblePageFormats); WRITE_COMMENT("This paper format is visible in the paper format dialog, separated by a colon"); WRITE_BOOL_PROP(autosaveEnabled); WRITE_INT_PROP(autosaveTimeout); WRITE_BOOL_PROP(addHorizontalSpace); WRITE_BOOL_PROP(addVerticalSpace); WRITE_BOOL_PROP(fixXinput); WRITE_BOOL_PROP(enableLeafEnterWorkaround); WRITE_COMMENT("If Xournal crashes if you e.g. unplug your mouse set this to true. If you have input problems, you can turn it of with false."); String pageInsertType = pageInsertTypeToString(this->pageInsertType);//.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:xournalpp,代码行数:101,
示例6: mtev_capabilities_tobuffstatic voidmtev_capabilities_tobuff(mtev_capsvc_closure_t *cl, eventer_func_t curr) { const char **mod_names; struct utsname utsn; char vbuff[128], bwstr[4]; mtev_hash_table *lc; mtev_hash_iter iter = MTEV_HASH_ITER_ZERO; const char *k; int klen, i, nmods; void *data; struct timeval now; struct dso_type *t; xmlDocPtr xmldoc; xmlNodePtr root, cmds, bi, ri, mods, feat; /* fill out capabilities */ /* Create an XML Document */ xmldoc = xmlNewDoc((xmlChar *)"1.0"); root = xmlNewDocNode(xmldoc, NULL, (xmlChar *)capabilities_namespace, NULL); xmlDocSetRootElement(xmldoc, root); /* Fill in the document */ mtev_build_version(vbuff, sizeof(vbuff)); xmlNewTextChild(root, NULL, (xmlChar *)"version", (xmlChar *)vbuff); snprintf(bwstr, sizeof(bwstr), "%d", (int)sizeof(void *)*8); /* Build info */ bi = xmlNewNode(NULL, (xmlChar *)"unameBuild"); xmlSetProp(bi, (xmlChar *)"bitwidth", (xmlChar *)bwstr); xmlAddChild(root, bi); xmlNewTextChild(bi, NULL, (xmlChar *)"sysname", (xmlChar *)UNAME_S); xmlNewTextChild(bi, NULL, (xmlChar *)"nodename", (xmlChar *)UNAME_N); xmlNewTextChild(bi, NULL, (xmlChar *)"release", (xmlChar *)UNAME_R); xmlNewTextChild(bi, NULL, (xmlChar *)"version", (xmlChar *)UNAME_V); xmlNewTextChild(bi, NULL, (xmlChar *)"machine", (xmlChar *)UNAME_M); /* Run info */ ri = xmlNewNode(NULL, (xmlChar *)"unameRun"); xmlSetProp(ri, (xmlChar *)"bitwidth", (xmlChar *)bwstr); xmlAddChild(root, ri); if(uname(&utsn) < 0) { xmlNewTextChild(ri, NULL, (xmlChar *)"error", (xmlChar *)strerror(errno)); } else { xmlNewTextChild(ri, NULL, (xmlChar *)"sysname", (xmlChar *)utsn.sysname); xmlNewTextChild(ri, NULL, (xmlChar *)"nodename", (xmlChar *)utsn.nodename); xmlNewTextChild(ri, NULL, (xmlChar *)"release", (xmlChar *)utsn.release); xmlNewTextChild(ri, NULL, (xmlChar *)"version", (xmlChar *)utsn.version); xmlNewTextChild(ri, NULL, (xmlChar *)"machine", (xmlChar *)utsn.machine); } /* features */ feat = xmlNewNode(NULL, (xmlChar *)"features"); xmlAddChild(root, feat); if(mtev_hash_size(&features)) { mtev_hash_iter iter2 = MTEV_HASH_ITER_ZERO; void *vfv; const char *f; int flen; while(mtev_hash_next(&features, &iter2, &f, &flen, &vfv)) { xmlNodePtr featnode; featnode = xmlNewNode(NULL, (xmlChar *)"feature"); xmlSetProp(featnode, (xmlChar *)"name", (xmlChar *)f); if(vfv) xmlSetProp(featnode, (xmlChar *)"version", (xmlChar *)vfv); xmlAddChild(feat, featnode); } } /* time (poor man's time check) */ gettimeofday(&now, NULL); snprintf(vbuff, sizeof(vbuff), "%llu.%03d", (unsigned long long)now.tv_sec, (int)(now.tv_usec / 1000)); xmlNewTextChild(root, NULL, (xmlChar *)"current_time", (xmlChar *)vbuff); cmds = xmlNewNode(NULL, (xmlChar *)"services"); xmlAddChild(root, cmds); lc = mtev_listener_commands(); while(mtev_hash_next(lc, &iter, &k, &klen, &data)) { xmlNodePtr cnode; char hexcode[11]; const char *name; eventer_func_t *f = (eventer_func_t *)k; mtev_hash_table *sc = (mtev_hash_table *)data; mtev_hash_iter sc_iter = MTEV_HASH_ITER_ZERO; const char *sc_k; int sc_klen; void *sc_data; name = eventer_name_for_callback(*f); cnode = xmlNewNode(NULL, (xmlChar *)"service"); xmlSetProp(cnode, (xmlChar *)"name", name ? (xmlChar *)name : NULL); if(*f == curr) xmlSetProp(cnode, (xmlChar *)"connected", (xmlChar *)"true"); xmlAddChild(cmds, cnode); while(mtev_hash_next(sc, &sc_iter, &sc_k, &sc_klen, &sc_data)) { xmlNodePtr scnode; char *name_copy, *version = NULL; eventer_func_t *f = (eventer_func_t *)sc_data;//.........这里部分代码省略.........
开发者ID:adriancole,项目名称:libmtev,代码行数:101,
示例7: mainint main(const int argc, const char ** const argv){ xmlDocPtr doc, request; xmlNodePtr root, topic_level, topic, request_node; xmlChar *out; size_t len; int ret; const char *path; void *context; void *topic_storage; char *income; size_t msg_size; char endpoint[FIELD_SIZE]; char field[FIELD_SIZE]; FILE *fp; /**** ****/ if (argc != 2) { printf("usage: topic_loader file.xml/n"); return OK; } printf(">>> [TopicLoader]: selected file: %s/n", argv[1]); path = argv[1]; /**** ****/ fp = fopen("topic_loader.ini", "r"); if (fp == NULL) { printf(">>> [TopicLoader]: IO ERROR. can't open /"topic_loader.ini/"/n"); return 1; } fscanf(fp,"%s %*s %s", field, endpoint); printf(">>> [TopicLoader]: field: %s; value: %s;/n", field, endpoint); fclose(fp); context = zmq_init(1); topic_storage = zmq_socket(context, ZMQ_REQ); zmq_connect(topic_storage, endpoint); ret = OK; doc = NULL; root = NULL; topic_level = NULL; request = NULL; doc = xmlReadFile(path, NULL, 0); if (!doc) { printf(">>> [TopicLoader]: libxml couldn't open the file/n"); return FAIL; } root = xmlDocGetRootElement(doc); if (!root) { printf(">>> [TopicLoader]: libxml couldn't get root element/n"); return FAIL; } topic_level = root->children; while (topic_level) { if (strcmp(topic_level->name, "topic")) { topic_level = topic_level->next; continue; } topic = NULL; request = NULL; out = NULL; request = NULL; request_node = NULL; topic = malloc(sizeof(xmlNode)); memcpy(topic, topic_level, sizeof(xmlNode)); topic->next = NULL; request = xmlNewDoc("1.0"); request_node = xmlNewNode(NULL, "request"); xmlNewProp(request_node, "type", "add_topic"); request_node->children = topic; xmlDocSetRootElement(request, request_node); xmlDocDumpFormatMemoryEnc(request, &out, &len, "UTF-8", 1); printf("%s/n", (char *)out); s_send(topic_storage, (char *)out, strlen((char *)out) + 1); income = s_recv(topic_storage, &msg_size); printf(">>> [TopicLoader]: TS responsed: %s/n", income); if (request_node) xmlFree(request_node); if (topic) free(topic); if (out) xmlFree(out); topic_level = topic_level->next; }//.........这里部分代码省略.........
开发者ID:NekoNe,项目名称:Monitor,代码行数:101,
示例8: testXmlwriterTree/** * testXmlwriterTree: * @file: the output file * * test the xmlWriter interface when writing to a subtree */voidtestXmlwriterTree(const char *file){ int rc; xmlTextWriterPtr writer; xmlDocPtr doc; xmlNodePtr node; xmlChar *tmp; /* Create a new XML DOM tree, to which the XML document will be * written */ doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION); if (doc == NULL) { printf ("testXmlwriterTree: Error creating the xml document tree/n"); return; } /* Create a new XML node, to which the XML document will be * appended */ node = xmlNewDocNode(doc, NULL, BAD_CAST "EXAMPLE", NULL); if (node == NULL) { printf("testXmlwriterTree: Error creating the xml node/n"); return; } /* Make ELEMENT the root node of the tree */ xmlDocSetRootElement(doc, node); /* Create a new XmlWriter for DOM tree, with no compression. */ writer = xmlNewTextWriterTree(doc, node, 0); if (writer == NULL) { printf("testXmlwriterTree: Error creating the xml writer/n"); return; } /* Start the document with the xml default for the version, * encoding ISO 8859-1 and the default for the standalone * declaration. */ rc = xmlTextWriterStartDocument(writer, NULL, MY_ENCODING, NULL); if (rc < 0) { printf("testXmlwriterTree: Error at xmlTextWriterStartDocument/n"); return; } /* Write a comment as child of EXAMPLE. * Please observe, that the input to the xmlTextWriter functions * HAS to be in UTF-8, even if the output XML is encoded * in iso-8859-1 */ tmp = ConvertInput("This is a comment with special chars: < C++ xmlFile函数代码示例 C++ xmlDocGetRootElement函数代码示例
|