zoukankan      html  css  js  c++  java
  • rapidxml测试

    /****************************/
    /* 网上看到例子记录下来防止忘记*/
    /****************************/
    /*xml文件
    config
    color
    red
    0.1
    <config>
    	<color>
    		<red>0.1</red>
    		<green>0.1</green>
    		<blue>0.1</blue>
    		<alpha>1.0</alpha>
    	</color>
    	<size>
    		<x>640</x>
    		<y>480</y>
    		<w>0</w>
    		<h>0</h>
    		<w >0</w>
    		<h >0</h>
    	</size>
    	<mode fullscreen="false">screen mode</mode>
    </config>
    */
    //生成config.xml文件
    /*#include <iostream> 
    #include "rapidxml.hpp"
    #include "rapidxml_utils.hpp"
    #include "rapidxml_print.hpp" 
    
    using namespace rapidxml; 
    
    int main() 
    { 
    	xml_document<> doc; 
    	xml_node<>* rot = doc.allocate_node(rapidxml::node_pi,doc.allocate_string("xml version='1.0'encoding='utf-8'")); 
    	doc.append_node(rot); 
    	xml_node<>* node = doc.allocate_node(node_element,"config","information"); 
    	xml_node<>* color = doc.allocate_node(node_element,"color",NULL); 
    	doc.append_node(node); 
    	node->append_node(color); 
    	color->append_node(doc.allocate_node(node_element,"red","0.1")); 
    	color->append_node(doc.allocate_node(node_element,"green","0.1")); 
    	color->append_node(doc.allocate_node(node_element,"blue","0.1")); 
    	color->append_node(doc.allocate_node(node_element,"alpha","1.0")); 
    	xml_node<>* size = doc.allocate_node(node_element,"size",NULL); 
    	size->append_node(doc.allocate_node(node_element,"x","640")); 
    	size->append_node(doc.allocate_node(node_element,"y","480")); 
    	node->append_node(size); 
    	xml_node<>* mode = doc.allocate_node(rapidxml::node_element,"mode","screen mode"); 
    	mode->append_attribute(doc.allocate_attribute("fullscreen","false")); 
    	node->append_node(mode); 
    	std::string text; 
    	rapidxml::print(std::back_inserter(text), doc, 0); 
    	std::cout<<text<<std::endl;
    	std::ofstream out("config.xml"); 
    	out << doc; 
    	system("PAUSE"); 
    	return EXIT_SUCCESS; 
    } 
    */
    
    //读取config.xml文件
    /*#include <iostream> 
    #include "rapidxml.hpp" 
    #include "rapidxml_utils.hpp"
    #include "rapidxml_print.hpp"
    
    using namespace rapidxml; 
    
    int main() 
    { 
    	file<> fdoc("config.xml"); 
    	std::cout<<fdoc.data()<<std::endl; 
    	xml_document<> doc; 
    	doc.parse<0>(fdoc.data()); 
    	std::cout<<doc.name()<<std::endl; 
    	//! 获取根节点 
    	xml_node<>* root = doc.first_node(); 
    	std::cout<<root->name()<<std::endl; 
    	//! 获取根节点第一个节点 
    	xml_node<>* node1 = root->first_node(); 
    	std::cout<<node1->name()<<std::endl; 
    	xml_node<>* node11 = node1->first_node(); 
    	std::cout<<node11->name()<<std::endl; 
    	std::cout<<node11->value()<<std::endl; 
    	//! 修改之后再次保存 
    	xml_node<>* size = root->first_node("size"); 
    	size->append_node(doc.allocate_node(node_element,"w ","0")); 
    	size->append_node(doc.allocate_node(node_element,"h ","0")); 
    	std::string text; 
    	rapidxml::print(std::back_inserter(text),doc,0); 
    	std::cout<<text<<std::endl; 
    	std::ofstream out("config.xml"); 
    	out << doc; 
    	system("PAUSE"); 
    	return EXIT_SUCCESS; 
    }
    */
    
  • 相关阅读:
    计算机代数系统Computer Algebra Software: Mathematica, Maxima, Pari/GP
    计算机代数系统对比:Computer Algebra Software: Mathematica, Maxima, Pari/GP
    搜索大质数的算法PHP版本【算法导论实践】
    使用maxima解决初等数论中的问题:
    练习使用文法剖析工具:
    反查字符的unicode码~
    Maxima Overview:
    Elementary number theory using Maxima
    Word文档结构图内容“越界”问题:
    Maxima, Maple, and Mathematica: the Summary~
  • 原文地址:https://www.cnblogs.com/602147629/p/2239067.html
Copyright © 2011-2022 走看看