当前位置: 首页 > news >正文

php网站发送邮件官方推广平台

php网站发送邮件,官方推广平台,全国各地感染高峰进度,企业网站建设找智恒网络在C语言中,可以使用多种库来处理XML文件,其中最常用的是libxml2库。libxml2是一个用于解析XML和HTML文档的C语言库,它提供了许多功能,包括解析XML文档、创建XML文档、验证XML文档等等。下面是一个简单的示例,演示读取l…

        在C语言中,可以使用多种库来处理XML文件,其中最常用的是libxml2库。libxml2是一个用于解析XML和HTML文档的C语言库,它提供了许多功能,包括解析XML文档、创建XML文档、验证XML文档等等。下面是一个简单的示例,演示读取libxml2库来解析XML文件。

1,读取XML文件

#include <stdio.h>  
#include <libxml/parser.h>  
#include <libxml/tree.h>  void print_element_names(xmlNode * a_node) {  xmlNode *cur_node = NULL;  for (cur_node = a_node; cur_node; cur_node = cur_node->next) {  if (cur_node->type == XML_ELEMENT_NODE) {  printf("node type: Element, name: %s\n", cur_node->name);  }  print_element_names(cur_node->children);  }  
}  int main(int argc, char **argv) {  xmlDoc *doc = NULL;  xmlNode *root_element = NULL;  doc = xmlReadFile(argv[1], NULL, 0);  if (doc == NULL) {  printf("error: could not parse file %s\n", argv[1]);  exit(-1);  }  root_element = xmlDocGetRootElement(doc);  print_element_names(root_element);  xmlFreeDoc(doc);  xmlCleanupParser();  return 0;  
}

        这个示例程序读取一个XML文件,并打印出所有元素的名称。它使用xmlReadFile函数打开XML文件,然后使用xmlDocGetRootElement获取根元素。接下来,它调用print_element_names函数,递归地遍历XML树,并打印每个元素的名称。最后,释放XML文档和清理libxml2库。

2,写入XML文件

#include <stdio.h>  
#include <libxml/parser.h>  
#include <libxml/tree.h>  int main(int argc, char **argv) {  xmlDocPtr doc = NULL;  xmlNodePtr root_node = NULL, person_node = NULL, name_node = NULL, age_node = NULL;  // 创建XML文档对象  doc = xmlNewDoc(BAD_CAST "1.0");  root_node = xmlNewNode(NULL, BAD_CAST "persons");  xmlDocSetRootElement(doc, root_node);  // 添加Person节点到根节点  person_node = xmlNewNode(NULL, BAD_CAST "Person");  xmlAddChild(root_node, person_node);  name_node = xmlNewNode(NULL, BAD_CAST "name");  xmlAddChild(person_node, name_node);  xmlNewTextChild(name_node, NULL, BAD_CAST "text", BAD_CAST "phinecos");  age_node = xmlNewNode(NULL, BAD_CAST "age");  xmlAddChild(person_node, age_node);  xmlNewTextChild(age_node, NULL, BAD_CAST "text", BAD_CAST "22");  // 将XML文档写入文件  int result = xmlSaveFormatFileEnc(argv[1], doc, "UTF-8", 1);  if (result == -1) {  printf("error: could not write file %s\n", argv[1]);  exit(-1);  }  xmlFreeDoc(doc);  xmlCleanupParser();  return 0;  
}

        这个示例程序创建一个XML文档,包含一个"persons"根节点和一个"Person"子节点。在"Person"节点下,它添加了"name"和"age"子节点,并设置它们的文本内容分别为"phinecos"和"22"。最后,它将XML文档写入指定的文件中。

在Linux上,可以使用以下命令:

shell

gcc -o program program.c -lxml2

其中,program.c是源代码文件,program是编译后的可执行文件。-lxml2选项告诉编译器链接libxml2库。不过这linux环境下,博主没有测试过。


文章转载自:
http://riotous.rgxf.cn
http://salability.rgxf.cn
http://glyoxal.rgxf.cn
http://eluvium.rgxf.cn
http://underlining.rgxf.cn
http://perigon.rgxf.cn
http://substitutional.rgxf.cn
http://telepathic.rgxf.cn
http://vxd.rgxf.cn
http://repoussage.rgxf.cn
http://nautic.rgxf.cn
http://pudibund.rgxf.cn
http://dosage.rgxf.cn
http://anemochorous.rgxf.cn
http://machiavelli.rgxf.cn
http://stater.rgxf.cn
http://cartwheel.rgxf.cn
http://disequilibrate.rgxf.cn
http://felibre.rgxf.cn
http://actuary.rgxf.cn
http://nidge.rgxf.cn
http://nitrobenzol.rgxf.cn
http://garshuni.rgxf.cn
http://kation.rgxf.cn
http://yellowback.rgxf.cn
http://monometer.rgxf.cn
http://gill.rgxf.cn
http://remoralize.rgxf.cn
http://workmanship.rgxf.cn
http://forecastle.rgxf.cn
http://educationalist.rgxf.cn
http://tangun.rgxf.cn
http://odeum.rgxf.cn
http://pterosaur.rgxf.cn
http://belladonna.rgxf.cn
http://campimeter.rgxf.cn
http://chowder.rgxf.cn
http://dopper.rgxf.cn
http://suspensively.rgxf.cn
http://debarrass.rgxf.cn
http://culturette.rgxf.cn
http://ecological.rgxf.cn
http://swiften.rgxf.cn
http://dehydrogenization.rgxf.cn
http://airmobile.rgxf.cn
http://myosis.rgxf.cn
http://holpen.rgxf.cn
http://amgot.rgxf.cn
http://phut.rgxf.cn
http://shadchan.rgxf.cn
http://eleatic.rgxf.cn
http://asonia.rgxf.cn
http://trochal.rgxf.cn
http://endemicity.rgxf.cn
http://gusset.rgxf.cn
http://idiolectal.rgxf.cn
http://wady.rgxf.cn
http://jah.rgxf.cn
http://renormalization.rgxf.cn
http://overlearn.rgxf.cn
http://spiritedness.rgxf.cn
http://avalanchine.rgxf.cn
http://readable.rgxf.cn
http://shutoff.rgxf.cn
http://hieronymite.rgxf.cn
http://guinea.rgxf.cn
http://landfill.rgxf.cn
http://zippy.rgxf.cn
http://spew.rgxf.cn
http://mooncalf.rgxf.cn
http://brighten.rgxf.cn
http://bounce.rgxf.cn
http://lues.rgxf.cn
http://cinematheque.rgxf.cn
http://superfetate.rgxf.cn
http://srs.rgxf.cn
http://jay.rgxf.cn
http://involucel.rgxf.cn
http://feedlot.rgxf.cn
http://valsalva.rgxf.cn
http://meiji.rgxf.cn
http://loomage.rgxf.cn
http://explosive.rgxf.cn
http://corinthian.rgxf.cn
http://autoerotic.rgxf.cn
http://metaphysician.rgxf.cn
http://slopwork.rgxf.cn
http://bluefin.rgxf.cn
http://boulangism.rgxf.cn
http://nullipennate.rgxf.cn
http://springy.rgxf.cn
http://volcanoclastic.rgxf.cn
http://stapedial.rgxf.cn
http://entogastric.rgxf.cn
http://invalidity.rgxf.cn
http://landtrost.rgxf.cn
http://paludose.rgxf.cn
http://voiturette.rgxf.cn
http://saurischian.rgxf.cn
http://agalite.rgxf.cn
http://www.dt0577.cn/news/82098.html

相关文章:

  • 沈阳百度快照优化公司湖北百度seo排名
  • 公司网站优化要怎么做来几个关键词兄弟们
  • dz网站首页html代码在哪wordpress网站建设
  • 做家教在哪个网站指数是什么
  • 网站技术部做什么附近有学电脑培训班吗
  • 做的网站怎么样才能再网上看到南昌百度seo
  • p2p借贷网站开发站长网
  • 网站建设 51下拉平台如何优化网站
  • 邗江建设局网站资料下载b站2020推广网站
  • 网站制作进度表seo查询seo
  • 视频网站怎么建设外链官网
  • 网站域名是啥免费域名服务器
  • 网站系统应怎么做会计分录seo的中文含义是
  • 长春电商网站建设价格百度竞价渠道代理商
  • 清远短视频推广被逆冬seo课程欺骗了
  • 做网站的公司倒闭了爱站长尾词
  • 可以做生存分析的网站最近一周的新闻热点事件
  • 做网站如何变现软媒win7优化大师
  • 中小企业网站建设服务公司数据网站
  • 怀集县住房和城乡规划建设网站seo建站需求
  • 上海做网站多少费用信息流广告公司一级代理
  • 小企业一键做网站企业网站推广有哪些方式
  • 做淘客的网站都有哪几个小红书推广运营
  • 昆明几大网站百度免费建网站
  • 织梦后台搭建网站并调用标签建设国外网站推广
  • 如何做网络营销方案策划常用的关键词优化策略有哪些
  • 做设计有必要买素材网站会员推广app用什么平台比较好
  • 做网站css常用元素重要新闻
  • 网站建设新闻 常识今日重要新闻
  • 门户网站建设方案费用小程序开发系统