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

网站企业管理培训课程什么网站做的号

网站企业管理培训课程,什么网站做的号,北京装修公司口碑最好的是哪家,网站开发交付验收文档2023年10月11日#xff0c;周三下午 目录 RapidXML的官网使用rapidXML读取XML文件中的元素的属性和值此次要读取的XML文件#xff1a;ReadExample.xml用于读取此XML文件的C代码运行结果使用rapidXML创建XML文件用于创建XML文件的C代码 如果上面的代码无法运行运行结果​编辑…2023年10月11日周三下午 目录 RapidXML的官网使用rapidXML读取XML文件中的元素的属性和值此次要读取的XML文件ReadExample.xml用于读取此XML文件的C代码运行结果使用rapidXML创建XML文件用于创建XML文件的C代码 如果上面的代码无法运行运行结果​编辑  RapidXML的官网 https://rapidxml.sourceforge.net/ RapidXML只有头文件不需要编译和配置。 使用rapidXML读取XML文件中的元素的属性和值 此次要读取的XML文件ReadExample.xml ?xml version1.0 encodingUTF-8? !-- XML声明,指定版本和编码 -- root !-- 根元素 -- Connector connectionTimeout20000 maxParameterCount1000 port8088 protocolHTTP/1.1 redirectPort8443/!--子元素Connector--book !-- 子元素book --nameC Primer/nameauthorStanley B. Lippman/authorprice59.00/price/book booknameHead First Java/nameauthorKathy Sierra/authorprice35.99/price/book /root 用于读取此XML文件的C代码 #include rapidxml.hpp #include iostream #include fstreamint main() {rapidxml::xml_document doc;// 打开XML文件std::ifstream file(ReadExample.xml);if (!file) {std::cerr Failed to open the XML file. std::endl;return 1;}// 读取XML文件内容到内存std::string xml_contents((std::istreambuf_iteratorchar(file)), std::istreambuf_iteratorchar());file.close();// 解析XML文档doc.parserapidxml::parse_default(xml_contents[0]);// 获取根元素rapidxml::xml_node* root doc.first_node(root);// 遍历子元素bookfor (rapidxml::xml_node* book root-first_node(book); book; book book-next_sibling(book)) {// 获取书名rapidxml::xml_node* name book-first_node(name);if (name) {std::cout Book Name: name-value() std::endl;}// 获取作者rapidxml::xml_node* author book-first_node(author);if (author) {std::cout Author: author-value() std::endl;}// 获取价格rapidxml::xml_node* price book-first_node(price);if (price) {std::cout Price: price-value() std::endl;}std::cout std::endl;}// 获取Connector元素的属性rapidxml::xml_node* connector root-first_node(Connector);if (connector) {std::cout Connector Attributes: std::endl;for (rapidxml::xml_attribute* attr connector-first_attribute(); attr; attr attr-next_attribute()) {std::cout Attribute Name: attr-name() , Value: attr-value() std::endl;}}return 0; }运行结果 使用rapidXML创建XML文件 用于创建XML文件的C代码 #include rapidxml.hpp #include rapidxml_print.hpp // 用于格式化输出XML #include iostream #include fstreamint main() {rapidxml::xml_document doc;// 创建根元素rapidxml::xml_node* root doc.allocate_node(rapidxml::node_element, root);doc.append_node(root);// 创建一个元素bookrapidxml::xml_node* book doc.allocate_node(rapidxml::node_element, book);root-append_node(book);// 创建book元素的子元素rapidxml::xml_node* name doc.allocate_node(rapidxml::node_element, name, C Primer);book-append_node(name);rapidxml::xml_node* author doc.allocate_node(rapidxml::node_element, author, Stanley B. Lippman);book-append_node(author);rapidxml::xml_node* price doc.allocate_node(rapidxml::node_element, price, 59.00);book-append_node(price);// 创建第二个book元素book doc.allocate_node(rapidxml::node_element, book);root-append_node(book);name doc.allocate_node(rapidxml::node_element, name, Head First Java);book-append_node(name);author doc.allocate_node(rapidxml::node_element, author, Kathy Sierra);book-append_node(author);price doc.allocate_node(rapidxml::node_element, price, 35.99);book-append_node(price);// 输出XML到文件std::ofstream file(created.xml);file doc;file.close();return 0; }如果上面的代码无法运行 如果你也遇到了如下这样的错误 那么可以按照下面这两篇文章来创建一个rapidxml_ext.hpp文件 c - RapidXML:无法打印 - 编译时错误 - IT工具网 (coder.work) c - RapidXML: Unable to print - Compile-time Error - Stack Overflow  rapidxml_ext.hpp文件的代码如下  //rapidxml_ext.hpp #pragma once#include rapidxml.hpp// Adding declarations to make it compatible with gcc 4.7 and greater // See https://stackoverflow.com/a/55408678 namespace rapidxml {namespace internal {template class OutIt, class Chinline OutIt print_children(OutIt out, const xml_nodeCh* node, int flags, int indent);template class OutIt, class Chinline OutIt print_attributes(OutIt out, const xml_nodeCh* node, int flags);template class OutIt, class Chinline OutIt print_data_node(OutIt out, const xml_nodeCh* node, int flags, int indent);template class OutIt, class Chinline OutIt print_cdata_node(OutIt out, const xml_nodeCh* node, int flags, int indent);template class OutIt, class Chinline OutIt print_element_node(OutIt out, const xml_nodeCh* node, int flags, int indent);template class OutIt, class Chinline OutIt print_declaration_node(OutIt out, const xml_nodeCh* node, int flags, int indent);template class OutIt, class Chinline OutIt print_comment_node(OutIt out, const xml_nodeCh* node, int flags, int indent);template class OutIt, class Chinline OutIt print_doctype_node(OutIt out, const xml_nodeCh* node, int flags, int indent);template class OutIt, class Chinline OutIt print_pi_node(OutIt out, const xml_nodeCh* node, int flags, int indent);} }#include rapidxml_print.hpp 然后在原来的代码的基础上引入头文件rapidxml_ext.hpp 注意头文件的顺序rapidxml_ext.hpp的引入必须先于rapidxml_print.hpp 改正的代码后如下 #include rapidxml.hpp #include rapidxml_ext.hpp //只多了这一行 #include rapidxml_print.hpp // 用于格式化输出XML #include iostream #include fstreamint main() {rapidxml::xml_document doc;// 创建根元素rapidxml::xml_node* root doc.allocate_node(rapidxml::node_element, root);doc.append_node(root);// 创建一个元素bookrapidxml::xml_node* book doc.allocate_node(rapidxml::node_element, book);root-append_node(book);// 创建book元素的子元素rapidxml::xml_node* name doc.allocate_node(rapidxml::node_element, name, C Primer);book-append_node(name);rapidxml::xml_node* author doc.allocate_node(rapidxml::node_element, author, Stanley B. Lippman);book-append_node(author);rapidxml::xml_node* price doc.allocate_node(rapidxml::node_element, price, 59.00);book-append_node(price);// 创建第二个book元素book doc.allocate_node(rapidxml::node_element, book);root-append_node(book);name doc.allocate_node(rapidxml::node_element, name, Head First Java);book-append_node(name);author doc.allocate_node(rapidxml::node_element, author, Kathy Sierra);book-append_node(author);price doc.allocate_node(rapidxml::node_element, price, 35.99);book-append_node(price);// 输出XML到文件std::ofstream file(created.xml);file doc;file.close();return 0; }运行结果
http://www.hkea.cn/news/14502251/

相关文章:

  • 昆山网站建设哪里好百度指数下载app
  • 怎么用dw英文版做网站做相亲网站 一年赚千万
  • 大连网站开发公司力推选仟亿科技美图秀秀网页版入口
  • 外贸网站论文邢台市防疫办电话是多少
  • 家具品牌网站怎么做登录wordpress后台的管理
  • 家政网站设计电脑浏览器打不开网页
  • 聊城建设网站大庆市让胡路区规划建设局网站
  • 雷州网站建设甘肃艾欧网络科技有限公司
  • 网站如何引入流量网站制作全过程
  • 湖北民族建设集团网站 天堂资源官网在线资源
  • 网站服务器试用搜索引擎技术基础
  • 做外贸用什么网站民宅挂在民宿网站上 保洁谁做
  • 制作钓鱼网站教程源码开发一个app需要什么条件
  • 网站地图模板.zip千库网app官方下载
  • 网站建设的数据库连接wordpress 新文章订阅
  • 网站备案现场网络营销课程培训内容
  • 建设网站公司哪家性价比高苏州旅游网站设计
  • wordpress 输出json关键词怎样做优化排名
  • 宁波专业建设网站建站公司河北seo推广平台
  • 网站备案怎么那么麻烦网站建设推广途径
  • wordpress 网站地址怎么样的网站合适做城市代理
  • 怎么发布个人网站网站设计服务平台
  • 做网站公司关键词成都模板网站建设
  • 做网站推广费用内丘网站
  • 靖江做网站单位中国平面设计网官网
  • 网站建设 手机网站后端开发工程师是做什么的
  • 外贸接单十大网站营销型网站建设应该注意什么
  • aspcms手机网站源码wordpress 搜索 字母
  • 做网站的时候字体应该多大溧阳城乡建设厅网站
  • dw做的网站与浏览器不匹配国外翻墙设计网站