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

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

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

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

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

示例1: notepad_save_file

int notepad_save_file(){	int i;	char file[256];	xmlDocPtr doc = NULL;                      // document pointer	xmlNodePtr root_node = NULL, node = NULL;  // node pointers	safe_snprintf (file, sizeof (file), "%snotes.xml", configdir);	doc = xmlNewDoc (BAD_CAST "1.0");	root_node = xmlNewNode (NULL, BAD_CAST "PAD");	xmlDocSetRootElement (doc, root_node);	for (i = 0; i < nr_notes; i++)	{		xmlChar* data;		char* subst_string = NULL;		// libxml2 expects all data in UTF-8 encoding.		xmlChar* name = toUTF8 (note_list[i].name, strlen (note_list[i].name));		substitute_char_with_string (note_list[i].text.data, &subst_string, '&', "&amp;");				data = toUTF8 (subst_string, strlen(subst_string));		node = xmlNewChild (root_node, NULL, BAD_CAST "NOTE", data);		xmlNewProp (node, BAD_CAST "NAME", name);		free (subst_string);		free (data);		free (name);	}	if (xmlSaveFormatFileEnc (file, doc, "UTF-8", 1) < 0)	{#ifndef WINDOWS		// error writing. try the data directory		safe_snprintf (file, sizeof (file), "%s/%s", datadir, "notes.xml");		if (xmlSaveFormatFileEnc(file, doc, "UTF-8", 1) < 0)		{			LOG_ERROR_OLD(cant_save_notes, file);		}#else		LOG_ERROR_OLD(cant_save_notes, file);#endif		return 0;	}	// Success!	return 1;}
开发者ID:xaphier,项目名称:Eternal-Lands,代码行数:48,


示例2: resetQuery

int resetQuery(){    int ret;    xmlDocPtr doc;    xmlNodePtr video_node, message_node;    xmlKeepBlanksDefault(0);    doc = xmlNewDoc(BAD_CAST "1.0");    /* create pod node as root node */    video_node = xmlNewNode(NULL, BAD_CAST "video");    xmlDocSetRootElement(doc, video_node);    message_node = xmlNewChild(video_node, NULL, BAD_CAST "message", BAD_CAST NULL);    xmlNewChild(message_node, NULL, BAD_CAST "query", BAD_CAST NULL);    // Save blank XML RESPONSE to File    ret = xmlSaveFormatFileEnc(XML_QUERY, doc, "UTF-8", 1);    // Dump to Console    // xmlSaveFormatFileEnc("-", doc, "UTF-8", 1);    xmlFreeDoc(doc);    return ret;}
开发者ID:jnbagale,项目名称:podvideoapp,代码行数:26,


示例3: savestatus

inline void savestatus() {	xmlNodePtr root = NULL;	xmlNodePtr node = NULL;	xmlChar* tmp = NULL;	if ((strlen(statname) > 0) && (status != NULL)) {		root = xmlDocGetRootElement(status);		if (root) {			xmlMutexLock(finishedMutex);			for (node = root->children; node; node = node->next) {				if (xmlStrcmp(node->name, "current") == 0) {					xmlMutexLock(pwdMutex);					tmp = xmlEncodeEntitiesReentrant(status, (const xmlChar*) &password);					xmlMutexUnlock(pwdMutex);					if (node->children) {					    if (password[0] == '/0')						xmlNodeSetContent(node->children, getfirstpassword());					    else						xmlNodeSetContent(node->children, tmp);					    }					xmlFree(tmp);				} else if ((finished == 1) && (xmlStrcmp(node->name,"good_password") == 0)) {					tmp =  xmlEncodeEntitiesReentrant(status, (const xmlChar*) &password_good);					if (node->children)						xmlNodeSetContent(node->children, tmp);					xmlFree(tmp);				}			}			xmlMutexUnlock(finishedMutex);		}		xmlSaveFormatFileEnc(statname, status, "UTF-8", 1);	}	return;}
开发者ID:Rudloff,项目名称:rarcrack-debian,代码行数:33,


示例4: printf

void project_t::diff_save() const {  if(unlikely(!osm))    return;  if(osm->is_clean(true)) {    printf("data set is clean, removing diff if present/n");    diff_remove_file();    return;  }  const std::string &diff_name = diff_filename(this);  printf("data set is dirty, generating diff/n");  /* write the diff to a new file so the original one needs intact until   * saving is completed */  const std::string ndiff = path + "save.diff";  xmlDocGuard doc(xmlNewDoc(BAD_CAST "1.0"));  xmlNodePtr root_node = xmlNewNode(nullptr, BAD_CAST "diff");  xmlNewProp(root_node, BAD_CAST "name", BAD_CAST name.c_str());  xmlDocSetRootElement(doc.get(), root_node);  std::for_each(osm->nodes.begin(), osm->nodes.end(), diff_save_objects<node_t>(root_node));  std::for_each(osm->ways.begin(), osm->ways.end(), diff_save_ways(root_node, osm));  std::for_each(osm->relations.begin(), osm->relations.end(), diff_save_objects<relation_t>(root_node));  xmlSaveFormatFileEnc(ndiff.c_str(), doc.get(), "UTF-8", 1);  /* if we reach this point writing the new file worked and we */  /* can move it over the real file */  if(renameat(-1, ndiff.c_str(), dirfd, diff_name.c_str()) != 0)    fprintf(stderr, "error %i when moving '%s' to '%s'/n", errno, ndiff.c_str(), diff_name.c_str());}
开发者ID:AMDmi3,项目名称:osm2go,代码行数:34,


示例5: main

int main (int argc, char **argv){  xmlDocPtr pdoc = NULL;  xmlNodePtr proot_node = NULL,pnode = NULL,pnode1 = NULL;  // 创建一个新文档并设置 root 节点  // 一个 XML 文件只有一个 root 节点  pdoc = xmlNewDoc (BAD_CAST "1.0");  proot_node = xmlNewNode (NULL, BAD_CAST "根节点");  xmlNewProp (proot_node, BAD_CAST "版本", BAD_CAST "1.0");  xmlDocSetRootElement (pdoc, proot_node);  pnode = xmlNewNode (NULL, BAD_CAST "子节点1");  // 创建上面 pnode 的子节点  xmlNewChild (pnode, NULL, BAD_CAST "子子节点1", BAD_CAST "信息");  // 添加子节点到 root 节点  xmlAddChild (proot_node, pnode);  pnode1 = xmlNewNode (NULL, BAD_CAST "子子节点1");  xmlAddChild (pnode, pnode1);  xmlAddChild (pnode1,xmlNewText (BAD_CAST "这是更低的节点,子子子节点1"));  // 还可以这样直接创建一个子节点到 root 节点上  xmlNewTextChild (proot_node, NULL, BAD_CAST "子节点2", BAD_CAST "子节点2的内容");  xmlNewTextChild (proot_node, NULL, BAD_CAST "子节点3", BAD_CAST "子节点3的内容");  // 保存 xml 为文件,如果没有给出文件名参数,就输出到标准输出  xmlSaveFormatFileEnc (argc > 1 ? argv[1]:"-", pdoc, "UTF-8", 1);  // 释放资源  xmlFreeDoc (pdoc);  xmlCleanupParser ();  xmlMemoryDump ();  return 0;}
开发者ID:wangkangluo1,项目名称:emacs-d,代码行数:35,


示例6: xmlCopyNode

/**/brief Convert an XML node from the old saved-games.xml format to the new format. * /details *   The old saved-games.xml format put all of the Player information in one file. *   The new saved-games.xml format only stores some Player information, but *   nothing that relies on loading the Simulation.  Everything in the old *   style format is by itself in a standalone xml file named after the player. * /todo This could save a copy of the old saved-games.xml to a backup location. * /param[in] doc The XML document. * /param[in] xnode The XML Node. * /return A new XML node that represents the PlayerInfo for the Player. */xmlNodePtr PlayerInfo::ConvertOldVersion( xmlDocPtr doc, xmlNodePtr node ) {	char buff[256];	xmlDocPtr xmlPtr;	xmlNodePtr  attr;	xmlNodePtr  copy = xmlCopyNode( node, 1);	string filename = "Resources/Definitions/"+ name +".xml";	LogMsg(INFO, "Converting %s to an xml file: %s ", name.c_str(), filename.c_str() );	xmlPtr = xmlNewDoc( BAD_CAST "1.0" );	xmlDocSetRootElement(xmlPtr, copy);	// Version information	snprintf(buff, sizeof(buff), "%d", EPIAR_VERSION_MAJOR);	xmlNewChild(copy, NULL, BAD_CAST "version-major", BAD_CAST buff);	snprintf(buff, sizeof(buff), "%d", EPIAR_VERSION_MINOR);	xmlNewChild(copy, NULL, BAD_CAST "version-minor", BAD_CAST buff);	snprintf(buff, sizeof(buff), "%d", EPIAR_VERSION_MICRO);	xmlNewChild(copy, NULL, BAD_CAST "version-macro", BAD_CAST buff);	xmlSaveFormatFileEnc( filename.c_str(), xmlPtr, "ISO-8859-1", 1);	xmlNodePtr new_node = xmlNewNode(NULL, BAD_CAST "player");	xmlNewChild(new_node, NULL, BAD_CAST "name", BAD_CAST GetName().c_str() );	xmlNewChild(new_node, NULL, BAD_CAST "file", BAD_CAST filename.c_str() );	if( (attr = FirstChildNamed(copy, "lastLoadTime")) ){		xmlNewChild(new_node, NULL, BAD_CAST "lastLoadTime", BAD_CAST NodeToString(doc,attr).c_str() );	}		return new_node;}
开发者ID:DuMuT6p,项目名称:Epiar,代码行数:43,


示例7: config_save

int config_save(xmlDocPtr pdoc, const char *filename){	if (access(filename, F_OK) == 0)		unlink(filename);	return xmlSaveFormatFileEnc(filename, pdoc, "UTF-8", 1); }
开发者ID:hushi55,项目名称:uaflow,代码行数:7,


示例8: xmlNewDoc

void MapaParser::saveMap(const std::string& fileName,    ReferenceCountPtr<Mapa>& mapa) {    // Define el nodo raiz del documento XML sobre el cual se va a trabajar.    xmlNodePtr nodoMapa;    // Crea el documento XML sobre el cual se va a trabajar.    this->document = xmlNewDoc(BAD_CAST "1.0");    // Crea el nodo raiz del documento XML sobre el cual se va a trabajar.    nodoMapa = xmlNewNode(NULL, BAD_CAST "mapa");    // Establece el nodo raìz del documento XML sobre el cual se va a trabajar.    xmlDocSetRootElement(this->document, nodoMapa);    // Persiste los paises del mapa.    persistirPaises(nodoMapa, mapa);    // Persiste los continentes del mapa.    persistirContinentes(nodoMapa, mapa);    // Persiste las reglas del mapa.    persistirReglas(nodoMapa, mapa);    // Escribe el documento XML a disco.    xmlSaveFormatFileEnc(fileName.c_str(), this->document, "UTF-8", 1);    // Libera el documento XML sobre el cual se va a trabajar.    xmlFreeDoc(this->document);    // Libera las variables globales que el parser XML haya inicializado.    xmlCleanupParser();}
开发者ID:lautaroezequielrinaldi,项目名称:risk-3d,代码行数:28,


示例9: init_xml

static void init_xml (void){    doc = xmlNewDoc ("1.0");    root_node = xmlNewNode (NULL, "sensor_network_logger");    xmlDocSetRootElement (doc, root_node);    xmlSaveFormatFileEnc (current_file, doc, "UTF-8", 1);}
开发者ID:135u5,项目名称:dynamiclinker,代码行数:7,


示例10: irc_network_manager_file_save

static gbooleanirc_network_manager_file_save (EmpathyIrcNetworkManager *self){  EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);  xmlDocPtr doc;  xmlNodePtr root;  if (priv->user_file == NULL)    {      DEBUG ("can't save: no user file defined");      return FALSE;    }  DEBUG ("Saving IRC networks");  doc = xmlNewDoc ("1.0");  root = xmlNewNode (NULL, "networks");  xmlDocSetRootElement (doc, root);  g_hash_table_foreach (priv->networks, (GHFunc) write_network_to_xml, root);  /* Make sure the XML is indented properly */  xmlIndentTreeOutput = 1;  xmlSaveFormatFileEnc (priv->user_file, doc, "utf-8", 1);  xmlFreeDoc (doc);  xmlCleanupParser ();  xmlMemoryDump ();  priv->have_to_save = FALSE;  return TRUE;}
开发者ID:Elleo,项目名称:empathy,代码行数:34,


示例11: saveJobToXML

int saveJobToXML(  job *pjob,      /* I - pointer to job */  const char *filename) /* I - filename to save to */  {  xmlDocPtr doc = NULL;       /* document pointer */  xmlNodePtr root_node;  int lenwritten = 0, rc = PBSE_NONE;  root_node = NULL;  char  log_buf[LOCAL_LOG_BUF_SIZE];  if ((doc = xmlNewDoc((const xmlChar*) "1.0")))    {    root_node = xmlNewNode(NULL, (const xmlChar*) JOB_TAG);    xmlDocSetRootElement(doc, root_node);    add_fix_fields(&root_node, (const job*)pjob);    add_union_fields(&root_node, (const job*)pjob);    if (add_attributes(&root_node, pjob))      return -1;#ifdef PBS_MOM    add_mom_fields(&root_node, (const job*)pjob);#endif /* PBS_MOM */#ifndef PBS_MOM    lock_ss();#endif /* !defined PBS_MOM */    lenwritten = xmlSaveFormatFileEnc(filename, doc, NULL, 1);#ifndef PBS_MOM    unlock_ss();#endif /* !defined PBS_MOM */    xmlFreeDoc(doc);    }  else    {    snprintf(log_buf, sizeof(log_buf), "could not create a new xml document");    log_event(    PBSEVENT_JOB,    PBS_EVENTCLASS_JOB,    pjob->ji_qs.ji_jobid,    log_buf);    rc = -1;         }  if (lenwritten <= 0)    {    snprintf(log_buf, sizeof(log_buf), "failed writing job to the xml file %s", filename);    log_event(      PBSEVENT_JOB,      PBS_EVENTCLASS_JOB,      pjob->ji_qs.ji_jobid,      log_buf);    rc = -1;    }  return rc;  } /* saveJobToXML */
开发者ID:hocks,项目名称:torque,代码行数:60,


示例12: diff_rename

bool diff_rename(project_t::ref oldproj, project_t *nproj){  const std::string &diff_name = project_diff_name(oldproj.get());  if(unlikely(diff_name.empty()))    return false;  fdguard difffd(oldproj->dirfd, diff_name.c_str(), O_RDONLY);  /* parse the file and get the DOM */  xmlDocGuard doc(xmlReadFd(difffd, nullptr, nullptr, XML_PARSE_NONET));  if(unlikely(!doc)) {    error_dlg(trstring("Error: could not parse file %1/n").arg(diff_name));    return false;  }  for (xmlNode *cur_node = xmlDocGetRootElement(doc.get()); cur_node != nullptr;       cur_node = cur_node->next) {    if (cur_node->type == XML_ELEMENT_NODE) {      if(likely(strcmp(reinterpret_cast<const char *>(cur_node->name), "diff") == 0)) {        xmlSetProp(cur_node, BAD_CAST "name", BAD_CAST nproj->name.c_str());        break;      }    }  }  xmlSaveFormatFileEnc((nproj->path + diff_filename(nproj)).c_str(), doc.get(), "UTF-8", 1);  return true;}
开发者ID:AMDmi3,项目名称:osm2go,代码行数:29,


示例13: exportDatabase

int exportDatabase( const char * filename, struct database_t * databaseList, int * databaseListTotal, struct userAttr_t * userAttr ){    int subscript;    char longStr[100000];    char message[500];    xmlNodePtr node;    xmlNodePtr content;    xmlNodePtr sonNode;    xmlNodePtr grandsonNode;    // create the doc and root node    xmlDocPtr doc = xmlNewDoc( BAD_CAST "1.0" );    xmlNodePtr root_node = xmlNewNode( NULL, BAD_CAST "databaseList" );    xitoa( longStr, *databaseListTotal);    xmlNewProp( root_node, BAD_CAST "databaseListTotal", BAD_CAST longStr );    if ( userAttr->userStatus == NULL )        xmlNewProp( root_node, BAD_CAST "userStatus", BAD_CAST "disable" );    else xmlNewProp( root_node, BAD_CAST "userStatus", BAD_CAST userAttr->userStatus );    if ( userAttr->mobileNumber != NULL )        xmlNewProp( root_node, BAD_CAST "userStatus", BAD_CAST userAttr->mobileNumber );    // set the root node    xmlDocSetRootElement( doc, root_node );    // if ( *xmlItemListAlarmTotal > *xmlItemListTotal ) *xmlItemListAlarmTotal = *xmlItemListTotal;    for (subscript=1; subscript <= *databaseListTotal; subscript++){        node = xmlNewNode( NULL, BAD_CAST "item" );        xmlAddChild( root_node, node );        // xitoa( longStr, subscript );        // xmlNewProp( node, BAD_CAST "subscript", BAD_CAST longStr );        sonNode = xmlNewNode( NULL, BAD_CAST "url" );        content = xmlNewCDataBlock( NULL, BAD_CAST databaseList[subscript].url, strlen(databaseList[subscript].url) );        xmlAddChild( sonNode, content );        xmlAddChild( node, sonNode );        sonNode = xmlNewNode( NULL, BAD_CAST "urlstatus" );        content = xmlNewCDataBlock( NULL, BAD_CAST databaseList[subscript].urlstatus, strlen(databaseList[subscript].urlstatus) );        xmlAddChild( sonNode, content );        xmlAddChild( node, sonNode );        sonNode = xmlNewNode( NULL, BAD_CAST "filenamePrefix" );        content = xmlNewCDataBlock( NULL, BAD_CAST databaseList[subscript].filenamePrefix, strlen(databaseList[subscript].filenamePrefix) );        xmlAddChild( sonNode, content );        xmlAddChild( node, sonNode );    }    int nRel = xmlSaveFormatFileEnc( filename, doc, "UTF-8", 1);    /*if (nRel != -1)        printf(" created, %d bytes./n", nRel);*/    xmlFreeDoc(doc);    if (nRel != -1) return 1;    else return 0;}
开发者ID:glace,项目名称:RSSReminder,代码行数:60,


示例14: callback_ofc_capable_switch

/* !DO NOT ALTER FUNCTION SIGNATURE! */int callback_ofc_capable_switch (void ** data, XMLDIFF_OP op, xmlNodePtr node, struct nc_err** error){	nc_verb_verbose("%s: data=%p, op=%d/n", __PRETTY_FUNCTION__, data, op);	xmlSaveFormatFileEnc("-", node->doc, "UTF-8", 1);	return EXIT_SUCCESS;}
开发者ID:bisdn,项目名称:of-config,代码行数:9,


示例15: xmlFreeTextWriter

void XMLExporter::close(){	//xmlTextWriterEndElement(m_writer);	xmlFreeTextWriter(m_writer);	xmlSaveFormatFileEnc(m_file.c_str(), m_doc, MY_ENCODING, 1); 	xmlCleanupParser();	xmlMemoryDump();}
开发者ID:skirk,项目名称:3rdYearMajor,代码行数:8,


示例16: main

intmain (int ac, char *ag[]){  CArray p;  uchar buf[200];  int set = 0;  if (ac != 4)    die (_("%s input file output"), ag[0]);  {    FILE *f = fopen (ag[2], "r");    if (!f)      die (_("open of %s failed"), ag[1]);    while (!feof (f))      {	int i = fread (buf, 1, sizeof (buf), f);	p.setpart (buf, p (), i);      }    fclose (f);  }  xmlDocPtr f;  f = xmlParseFile (ag[1]);  if (!f)    die (_("can not parse %s"), ag[1]);  xmlNodePtr n = xmlDocGetRootElement (f);  if (n->type != XML_ELEMENT_NODE      || (strcmp ((const char *) n->name, "DeviceConfig")	  && strcmp ((const char *) n->name, "DeviceDesc")))    die (_("wrong format"));  xmlNodePtr cld = n->children;  while (cld)    {      if (cld->type == XML_ELEMENT_NODE)	{	  const char *name = (const char *) cld->name;	  if (!strcmp (name, "ProgramID"))	    {	      setcontent (cld, p);	      set = 1;	    }	}      cld = cld->next;    }  if (!set)    die (_("ProgramID not found"));  if (xmlSaveFormatFileEnc (ag[3], f, "UTF-8", 1) < 0)    die (_("write to %s failed"), ag[3]);  xmlFreeDoc (f);}
开发者ID:AdrienCourtois,项目名称:Domoleaf,代码行数:58,


示例17: main

int main(int argc, char **argv){    xmlDocPtr doc = NULL;   //定义解析文档指针    xmlNodePtr cur = NULL;  //定义结点指针(你需要它为了在各个结点间移动)    xmlNodePtr child = NULL;    xmlChar *key = NULL;    char *psfilename = NULL;    xmlChar *value = NULL;#if 0    if (argc < 1)    {        printf("error: Usage: %s filename/n" , argv[0]);        return;    }    psfilename = argv[1];#endif    doc = xmlParseFile("w.xml");     //doc = xmlReadFile(psfilename, MY_ENCODING, 256);  //解析文件    if (doc == NULL )    {        fprintf(stderr,"Document not parsed successfully. /n");        return;    }    cur = xmlDocGetRootElement(doc);  //确定文档根元素    if (cur == NULL)/*检查确认当前文档中包含内容*/    {        fprintf(stderr,"empty document/n");        xmlFreeDoc(doc);        return;    }    if (xmlStrcmp(cur->name, (const xmlChar *)"socket"))//roor node--socket    {        fprintf(stderr,"document of the wrong type, socket node != socket");        xmlFreeDoc(doc);        return;    }    printf("root node: %s/n", cur->name);    cur = cur->xmlChildrenNode;//socket_type    while(cur != NULL)    {        if ((!xmlStrcmp(cur->name, (const xmlChar *)"socket_type")))        {            value = xmlGetProp(cur, (const xmlChar *)"type");//attributeaa            printf("socket_type: %s/n", value);            parseStory(doc, cur);            xmlFree(value);        }        cur = cur->next;    }    xmlSaveFormatFileEnc("w.xml", doc, "UTF-8", 1);    xmlFreeDoc(doc);    return(0);}
开发者ID:jiajuwu,项目名称:JSON,代码行数:58,


示例18: chatroom_manager_file_save

static gbooleanchatroom_manager_file_save (EmpathyChatroomManager *manager){  EmpathyChatroomManagerPriv *priv;  xmlDocPtr doc;  xmlNodePtr root;  GList *l;  priv = GET_PRIV (manager);  priv->writing = TRUE;  doc = xmlNewDoc ((const xmlChar *) "1.0");  root = xmlNewNode (NULL, (const xmlChar *) "chatrooms");  xmlDocSetRootElement (doc, root);  for (l = priv->chatrooms; l; l = l->next)    {      EmpathyChatroom *chatroom;      xmlNodePtr       node;      const gchar     *account_id;      chatroom = l->data;      if (!empathy_chatroom_is_favorite (chatroom))        continue;      account_id = tp_proxy_get_object_path (empathy_chatroom_get_account (            chatroom));      node = xmlNewChild (root, NULL, (const xmlChar *) "chatroom", NULL);      xmlNewTextChild (node, NULL, (const xmlChar *) "name",        (const xmlChar *) empathy_chatroom_get_name (chatroom));      xmlNewTextChild (node, NULL, (const xmlChar *) "room",        (const xmlChar *) empathy_chatroom_get_room (chatroom));      xmlNewTextChild (node, NULL, (const xmlChar *) "account",        (const xmlChar *) account_id);      xmlNewTextChild (node, NULL, (const xmlChar *) "auto_connect",        empathy_chatroom_get_auto_connect (chatroom) ?        (const xmlChar *) "yes" : (const xmlChar *) "no");      xmlNewTextChild (node, NULL, (const xmlChar *) "always_urgent",        empathy_chatroom_is_always_urgent (chatroom) ?        (const xmlChar *) "yes" : (const xmlChar *) "no");    }  /* Make sure the XML is indented properly */  xmlIndentTreeOutput = 1;  DEBUG ("Saving file:'%s'", priv->file);  xmlSaveFormatFileEnc (priv->file, doc, "utf-8", 1);  xmlFreeDoc (doc);  xmlMemoryDump ();  priv->writing = FALSE;  return TRUE;}
开发者ID:DylanMcCall,项目名称:Empathy---Hide-contact-groups,代码行数:57,


示例19: eXmlInvalid

int cXmlDoc::write(const char* filename, bool indent, const char* encoding) {    if (!m_doc)        throw eXmlInvalid("Tried to write bad document");    if (indent) {        return xmlSaveFormatFileEnc(filename, m_doc.get(), encoding, 1);    } else {        return xmlSaveFileEnc(filename, m_doc.get(), encoding);    }}
开发者ID:Joeywp,项目名称:OVLMake,代码行数:10,


示例20: write_container

int write_container(char* opf_path){    xmlDocPtr doc = NULL;       /* document pointer */    xmlNodePtr container = NULL, rootFiles = NULL, rootFile = NULL;/* node pointers */    xmlDtdPtr dtd = NULL;       /* DTD pointer */    char buff[256];    int i, j;    LIBXML_TEST_VERSION;    /*      * Creates a new document, a node and set it container as the root node     */    doc = xmlNewDoc(BAD_CAST "1.0");    container = xmlNewNode(NULL, BAD_CAST "container");    xmlDocSetRootElement(doc, container);    xmlNewProp(container, BAD_CAST "version", BAD_CAST "1.0");    xmlNewProp(container, BAD_CAST "xmlns", BAD_CAST "urn:oasis:names:tc:opendocument:xmlns:container");    /*      * xmlNewChild() creates a new node, which is "attached" as child node     * of root_node node.      */    rootFiles = xmlNewChild(container, NULL, BAD_CAST "rootfiles",                BAD_CAST NULL);    /*      * The same as above, but the new child node doesn't have a content      */    rootFile = xmlNewChild(rootFiles, NULL, BAD_CAST "rootfile", NULL);    xmlNewProp(rootFiles, BAD_CAST "full-path", BAD_CAST opf_path);    xmlNewProp(rootFiles, BAD_CAST "media-type", BAD_CAST "application/oebps-package+xml");    /*      * Dumping document to stdio or file     */    xmlSaveFormatFileEnc("container.xml", doc, "UTF-8", 1);    /*free the document */    xmlFreeDoc(doc);    /*     *Free the global variables that may     *have been allocated by the parser.     */    xmlCleanupParser();    /*     * this is to debug memory for regression tests     */    xmlMemoryDump();    return(0);}
开发者ID:DDKnoll,项目名称:GC_HTML_to_ePub,代码行数:55,


示例21: write_all_notice_to_xmlfile

// write it to filevoid write_all_notice_to_xmlfile(char *filename, p_notice_element head){#ifdef WIN32	char gbk_filename[BUFFER_MAX_SIZE];	u2g(filename,strlen(filename), gbk_filename, BUFFER_MAX_SIZE);	msdosify(gbk_filename);#endif	xmlDocPtr doc = NULL;	xmlNodePtr root_node = NULL, notice = NULL;	doc = xmlNewDoc(BAD_CAST "1.0");	root_node = xmlNewNode(NULL, BAD_CAST "root");	xmlDocSetRootElement(doc, root_node);	char number_buf[8];	p_notice_element p = head->next;	while(p)	{		xmlNodePtr notice_id = NULL, notice_publisher = NULL, notice_time = NULL,notice_title = NULL ,notice_content = NULL;		sprintf(number_buf,"%d",p->notice_id);		notice = xmlNewChild(root_node, NULL, BAD_CAST "notice", BAD_CAST "");		xmlNewProp(notice, BAD_CAST "isHighLight", p->is_highlight == TRUE? BAD_CAST "true":BAD_CAST "false");		notice_id = xmlNewChild(notice, NULL ,BAD_CAST "id" , BAD_CAST number_buf);		notice_publisher = xmlNewChild(notice, NULL ,BAD_CAST "publisher" , BAD_CAST p->notice_publisher);		notice_time = xmlNewChild(notice, NULL ,BAD_CAST "time" , BAD_CAST p->notice_time);		notice_title = xmlNewChild(notice, NULL ,BAD_CAST "title" , BAD_CAST p->notice_title);		notice_content = xmlNewChild(notice, NULL ,BAD_CAST "content" , BAD_CAST p->notice_body);		p = p->next;	}#ifdef WIN32	xmlSaveFormatFileEnc(gbk_filename, doc, "UTF-8", 1);#endif#ifndef WIN32	xmlSaveFormatFileEnc(filename, doc, "UTF-8", 1);#endif	/*free the document */	xmlFreeDoc(doc);	xmlCleanupParser();	xmlMemoryDump();//debug memory for regression tests*/}
开发者ID:tiancaihb,项目名称:gypsophila,代码行数:43,


示例22: Save

bool CSpmXml::Save(const QString& strFileName){	if (0 == m_pXMLDoc)		return false;	if (-1 == xmlSaveFormatFileEnc(strFileName.toLocal8Bit(), m_pXMLDoc, "UTF-8", 1))		return false;	SetModified(false);	return true;}
开发者ID:smurav,项目名称:gis36,代码行数:11,


示例23: xmlDiaSaveFile

/*! * /brief Save an XML document to a file. * @param filename The file to save to. * @param cur The XML document structure. * @return The return value of xmlSaveFormatFileEnc. * @todo Get the proper defn of the return value from libxml2. * /ingroup DiagramXmlIo */intxmlDiaSaveFile (const char *filename,		xmlDocPtr   cur){  int old, ret;  old = xmlKeepBlanksDefault (0);  ret = xmlSaveFormatFileEnc (filename,cur, "UTF-8", 1);  xmlKeepBlanksDefault (old);  return ret;}
开发者ID:UIKit0,项目名称:dia,代码行数:19,


示例24: cfgw_modify_file

/* * This function modifies a config file according to the calibrated values. */int cfgw_modify_file(char* file){  xmlDoc *doc = NULL;  xmlNode *root_element = NULL;  int ret = 0;  char file_path[PATH_MAX];  snprintf(file_path, sizeof(file_path), "%s%s%s%s", gimx_params.homedir, GIMX_DIR, CONFIG_DIR, file);  /*   * this initialize the library and check potential ABI mismatches   * between the version it was compiled for and the actual shared   * library used.   */  LIBXML_TEST_VERSION  /*parse the file and get the DOM */  doc = xmlReadFile(file_path, NULL, 0);#ifdef WIN32  if(!xmlFree) xmlMemGet(&xmlFree,&xmlMalloc,&xmlRealloc,NULL);#endif  if (doc != NULL)  {    /*Get the root element node */    root_element = xmlDocGetRootElement(doc);    if(root_element != NULL)    {      ret = ProcessRootElement(root_element);    }    else    {      ret = -1;      printf("error: no root element/n");    }    if(ret != -1)    {      xmlSaveFormatFileEnc(file_path, doc, "UTF-8", 1);    }  }  else  {    ret = -1;    printf("error: could not parse file %s/n", file_path);  }  /*free the document */  xmlFreeDoc(doc);  return ret;}
开发者ID:NoPublic,项目名称:GIMX,代码行数:57,


示例25: project_save_xml

static voidproject_save_xml(CProject *project){		xmlDocPtr doc;	xmlNodePtr root_node;	xmlNodePtr node;	GList *iterator;	gchar *xml_path;	doc = xmlNewDoc(BAD_CAST ("1.0"));	root_node = xmlNewNode(NULL, BAD_CAST ("Project"));	xmlDocSetRootElement(doc, root_node);	xmlNewChild(root_node, NULL, BAD_CAST ("Type"), project->project_type == PROJECT_C? BAD_CAST ("C"): BAD_CAST ("C++"));	xmlNewChild(root_node, NULL, BAD_CAST ("Name"), BAD_CAST (project->project_name));	xmlNewChild(root_node, NULL, BAD_CAST ("Path"), BAD_CAST (project->project_path));	node = xmlNewChild(root_node, NULL, BAD_CAST ("Headers"), NULL);	for (iterator = project->header_list; iterator; iterator = iterator->next) {		gchar *filepath;		filepath = (gchar *) iterator->data;		xmlNewChild(node, NULL, BAD_CAST ("File"), BAD_CAST (filepath));	}	node = xmlNewChild(root_node, NULL, BAD_CAST ("Sources"), NULL);	for (iterator = project->source_list; iterator; iterator = iterator->next) {		gchar *filepath;		filepath = (gchar *) iterator->data;		xmlNewChild(node, NULL, BAD_CAST ("File"), BAD_CAST (filepath));	}	node = xmlNewChild(root_node, NULL, BAD_CAST ("Resources"), NULL);	for (iterator = project->resource_list; iterator; iterator = iterator->next) {		gchar *filepath;		filepath = (gchar *) iterator->data;		xmlNewChild(node, NULL, BAD_CAST ("File"), BAD_CAST (filepath));	}	xmlNewChild(root_node, NULL, BAD_CAST ("LIBS"), BAD_CAST (project->libs));	xmlNewChild(root_node, NULL, BAD_CAST ("OPTS"), BAD_CAST (project->opts));	xml_path = (gchar *) g_malloc (MAX_PATH_LENTH);	g_strlcpy (xml_path, project->project_path, MAX_PATH_LENTH);	g_strlcat (xml_path, "/project.cfp", MAX_PATH_LENTH);	xmlSaveFormatFileEnc(xml_path, doc, "UTF-8", 1);	xmlFreeDoc(doc);	xmlCleanupParser();	g_free (xml_path);}
开发者ID:nirvanan,项目名称:Codefox,代码行数:53,


示例26: cal_write_notes

voidcal_write_notes (GUI *appGUI){xmlDocPtr doc;xmlNodePtr main_node, node, note_node, dc_node;xmlAttrPtr attr;GtkTreeIter iter;GSList *lnode;struct note *a;gchar *category, *color_str;gint i;xmlChar *escaped;	if ((appGUI->save_status & WRT_CALENDAR_NOTES) != 0) return;	appGUI->save_status |= WRT_CALENDAR_NOTES;	doc = xmlNewDoc ((const xmlChar *) "1.0");	attr = xmlNewDocProp (doc, (const xmlChar *) "encoding", (const xmlChar *) "utf-8");	main_node = xmlNewNode (NULL, (const xmlChar *) CALENDAR_NOTES_NAME);	xmlDocSetRootElement (doc, main_node);	node = xmlNewChild (main_node, NULL, (const xmlChar *) CALENDAR_DAY_CATEGORIES_NAME, (xmlChar *) NULL);	i = 0;	while (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (appGUI->opt->calendar_category_store), &iter, NULL, i++)) {		gtk_tree_model_get (GTK_TREE_MODEL (appGUI->opt->calendar_category_store), &iter, 1, &color_str, 2, &category, -1);		escaped = xmlEncodeEntitiesReentrant(doc, (const xmlChar *) category);		dc_node = xmlNewChild (node, NULL, (const xmlChar *) "name", (xmlChar *) escaped);		g_free (category);        xmlFree (escaped);		escaped = xmlEncodeEntitiesReentrant(doc, (const xmlChar *) color_str);		xmlNewProp (dc_node, (const xmlChar *) "color", (xmlChar *) escaped);		g_free (color_str);        xmlFree (escaped);	}	for (i = 0, lnode = appGUI->cal->notes_list; lnode; lnode = lnode->next, i++) {		a = g_slist_nth_data (appGUI->cal->notes_list, i);		note_node = xmlNewChild (main_node, NULL, (const xmlChar *) "note", (xmlChar *) NULL);		utl_xml_put_uint ("date", a->date, note_node);		utl_xml_put_str ("color", a->color, note_node, doc);		utl_xml_put_str ("message", a->note, note_node, doc);	}	xmlSaveFormatFileEnc (prefs_get_config_filename (CALENDAR_NOTES_FILENAME, appGUI), doc, "utf-8", 1);	xmlFreeProp (attr);	xmlFreeDoc (doc);	appGUI->save_status &= ~WRT_CALENDAR_NOTES;}
开发者ID:rosedu,项目名称:osmo,代码行数:53,


示例27: pe_process_state

int32_tpe_process_state(xmlDocPtr doc,		 pe_resource_execute_t exec_fn,		 pe_transition_completed_t done_fn,		 void *user_data, int debug){	crm_graph_t *transition = NULL;	xmlNode *xml_input = xmlDocGetRootElement(doc);	qb_enter();	if (working_set) {		qb_log(LOG_ERR, "Transition already in progress");		qb_leave();		return -EEXIST;	}	transition_count++;	if (debug) {		char filename[PATH_MAX];		assert(validate_xml(xml_input, "pacemaker-1.2", FALSE) == TRUE);		snprintf(filename, PATH_MAX, "/tmp/pe-%d-%d.xml",			 getpid(), transition_count);		xmlSaveFormatFileEnc(filename, doc, "UTF-8", 1);		qb_log(LOG_INFO, "Executing deployable transition [%s]",		       filename);	} else {		qb_log(LOG_INFO, "Executing deployable transition [%d]",		       transition_count);	}	working_set = calloc(1, sizeof(pe_working_set_t));	run_fn = exec_fn;	completed_fn = done_fn;	run_user_data = user_data;	set_graph_functions(&graph_exec_fns);	set_working_set_defaults(working_set);	/* calculate output */	do_calculations(working_set, xml_input, NULL);	transition = unpack_graph(working_set->graph, __func__);	//print_graph(LOG_INFO, transition);	graph_updated = TRUE;	qb_loop_job_add(NULL, QB_LOOP_HIGH, transition, process_next_job);	qb_leave();	return 0;}
开发者ID:sdake,项目名称:pacemaker-cloud,代码行数:53,


示例28: xml_create_by_vm2vm

void xml_create_by_vm2vm(char *xmlfilename){	int i;	xmlDocPtr doc = NULL;       	xmlNodePtr root_node = NULL, node = NULL, node1 = NULL;	//建立根节点	doc = xmlNewDoc(BAD_CAST "1.0");	root_node = xmlNewNode(NULL, BAD_CAST "DATA");	xmlNewProp(root_node,BAD_CAST"VERSION",BAD_CAST"0.1");	xmlDocSetRootElement(doc, root_node);	/*对没一条亲和性关系输出到XML*/	for(i=0;i<_xpthis->sd->v2v_total;i++){		/*生成主节点*/		node = xmlNewNode(NULL, BAD_CAST "AFFINITY");		/*生成AT属性*/		xmlNewProp(node,BAD_CAST"AT",BAD_CAST _xpthis->sd->v2vlist[i].at);		/*生成TYPE属性*/		xmlNewProp(node,BAD_CAST"TYPE",BAD_CAST NumToChar (_xpthis->sd->v2vlist[i].affinity));		/*生成TRAFFIC属性*/		if(_xpthis->sd->v2vlist[i].traffic>0)			xmlNewProp(node,BAD_CAST"TRAFFIC",BAD_CAST DoubleToChar (_xpthis->sd->v2vlist[i].traffic,0));		else			xmlNewProp(node,BAD_CAST"TRAFFIC",BAD_CAST " ");		/*生成DELAY属性*/		xmlNewProp(node,BAD_CAST"DELAY",BAD_CAST DoubleToChar (_xpthis->sd->v2vlist[i].delay,0));		/*生成VMIDS属性*/		xmlNewProp(node,BAD_CAST"VMIDS",BAD_CAST _xpthis->sd->v2vlist[i].vmids);		/*		xmlNewProp(node,BAD_CAST"DSTID",BAD_CAST NumToChar(_xpthis->sd->v2vlist[i].p_dst_vm->host.id));		xmlNewProp(node,BAD_CAST"SRCID",BAD_CAST NumToChar(_xpthis->sd->v2vlist[i].p_src_vm->host.id));		*/		xmlAddChild(root_node, node);	}	/*生成文件*/	xmlSaveFormatFileEnc(xmlfilename, doc, "UTF-8", 1);		/*释放*/	xmlFreeDoc(doc);	xmlCleanupParser();	xmlMemoryDump();}
开发者ID:suro1995,项目名称:scheduler-alogrithm,代码行数:52,


示例29: gc_wordlist_save

void gc_wordlist_save(GcomprisWordlist *wordlist){	GSList *listlevel,*listword;	LevelWordlist *level;	gchar *filename, *tmp;	xmlNodePtr wlnode, levelnode, node;	xmlDocPtr doc;	if(!wordlist)		return;	doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);	if(!doc)		return;	node = xmlNewNode(NULL, BAD_CAST "GCompris");	xmlDocSetRootElement(doc,node);	wlnode = xmlNewChild(node, NULL, BAD_CAST "Wordlist", NULL);	if(wordlist->name)		xmlSetProp(wlnode, BAD_CAST "name", BAD_CAST wordlist->name);	if(wordlist->description)		xmlSetProp(wlnode, BAD_CAST "description", BAD_CAST wordlist->description);	if(wordlist->locale)		xmlSetProp(wlnode, BAD_CAST "locale", BAD_CAST wordlist->locale);	for(listlevel = wordlist->levels_words; listlevel; listlevel = listlevel->next)	{		level = (LevelWordlist*)listlevel->data;		levelnode = xmlNewChild(wlnode, NULL, BAD_CAST "level", NULL);		if((tmp = g_strdup_printf("%d", level->level)))		{			xmlSetProp(levelnode, BAD_CAST "value", BAD_CAST tmp);			g_free(tmp);		}		for(listword = level->words; listword; listword=listword->next)		{			xmlNodeAddContent(levelnode, BAD_CAST listword->data);			xmlNodeAddContent(levelnode, BAD_CAST " ");		}	}	filename = gc_file_find_absolute_writeable(wordlist->filename);	if(filename)	{		if(xmlSaveFormatFileEnc(filename, doc, NULL, 1)<0)		{			g_warning("Fail to write %s", filename);			g_free(filename);		}		g_free(filename);	}	xmlFreeDoc(doc);}
开发者ID:afenkart,项目名称:gcompris-devel,代码行数:52,


示例30: xmlDiaSaveFile

/** Save an XML document to a file. * @param filename The file to save to. * @param cur The XML document structure. * @return The return value of xmlSaveFormatFileEnc. * @bug Get the proper defn of the return value from libxml2. */intxmlDiaSaveFile(const char *filename,                   xmlDocPtr cur){    int old = 0, ret;    if (pretty_formated_xml)        old = xmlKeepBlanksDefault (0);    ret = xmlSaveFormatFileEnc (filename,cur, "UTF-8", pretty_formated_xml ? 1 : 0);    if (pretty_formated_xml)        xmlKeepBlanksDefault (old);    return ret;}
开发者ID:yjdwbj,项目名称:c_struct_gui,代码行数:19,



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


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