青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

牽著老婆滿街逛

嚴以律己,寬以待人. 三思而后行.
GMail/GTalk: yanglinbo#google.com;
MSN/Email: tx7do#yahoo.com.cn;
QQ: 3 0 3 3 9 6 9 2 0 .

Quick notes on how to use RapidXML

轉(zhuǎn)載自:http://www.ffuts.org/blog/quick-notes-on-how-to-use-rapidxml/

There’s a C++ XML library called RapidXML which is perfect for most non-enterprise uses of XML. I wouldn’t call this a tutorial, but I hope this ends up helping someone. The documentation isn’t very explicit on how to output an XML declaration, for example.

How to create your XML from scratch and then output this XML into a string, with an XML declaration:

<?xml version="1.0" encoding="utf-8"?>
<rootnode version="1.0" type="example">
 
<childnode/>
</rootnode>
using namespace rapidxml;

xml_document
<> doc;

// xml declaration
xml_node
<>* decl = doc.allocate_node(node_declaration);
decl
->append_attribute(doc.allocate_attribute("version", "1.0"));
decl
->append_attribute(doc.allocate_attribute("encoding", "utf-8"));
doc
.append_node(decl);

// root node
xml_node
<>* root = doc.allocate_node(node_element, "rootnode");
root
->append_attribute(doc.allocate_attribute("version", "1.0"));
root
->append_attribute(doc.allocate_attribute("type", "example"));
doc
.append_node(root);

// child node
xml_node
<>* child = doc.allocate_node(node_element, "childnode");
root
->append_node(child);

std
::string xml_as_string;
// watch for name collisions here, print() is a very common function name!
print(std::back_inserter(xml_as_string), doc);
// xml_as_string now contains the XML in string form, indented
// (in all its angle bracket glory)

std
::string xml_no_indent;
// print_no_indenting is the only flag that print() knows about
print(std::back_inserter(xml_as_string), doc, print_no_indenting);
// xml_no_indent now contains non-indented XML


Parsing and traversing an XML document like this one:

<?xml version="1.0" encoding="utf-8"?>
<rootnode version="1.0" type="example">
 
<childnode entry="1">
   
<evendeepernode attr1="cat" attr2="dog"/>
   
<evendeepernode attr1="lion" attr2="wolf"/>
 
</childnode>
 
<childnode entry="2">
 
</childnode>
</rootnode>
void traverse_xml(std::string input_xml)
{
   
// (input_xml contains the above XML)

   
// make a safe-to-modify copy of input_xml
   
// (you should never modify the contents of an std::string directly)
    vector
<char> xml_copy(input_xml.begin(), input_xml.end());
    xml_copy
.push_back('\0');

   
// only use xml_copy from here on!
    xml_document
<> doc;
   
// we are choosing to parse the XML declaration
   
// parse_no_data_nodes prevents RapidXML from using the somewhat surprising
   
// behavior of having both values and data nodes, and having data nodes take
   
// precedence over values when printing
   
// >>> note that this will skip parsing of CDATA nodes <<<
    doc
.parse<parse_declaration_node | parse_no_data_nodes>(&xml_copy[0]);

   
// alternatively, use one of the two commented lines below to parse CDATA nodes,
   
// but please note the above caveat about surprising interactions between
   
// values and data nodes (also read http://www.ffuts.org/blog/a-rapidxml-gotcha/)
   
// if you use one of these two declarations try to use data nodes exclusively and
   
// avoid using value()
   
//doc.parse<parse_declaration_node>(&xml_copy[0]); // just get the XML declaration
   
//doc.parse<parse_full>(&xml_copy[0]); // parses everything (slowest)

   
// since we have parsed the XML declaration, it is the first node
   
// (otherwise the first node would be our root node)
   
string encoding = doc.first_node()->first_attribute("encoding")->value();
   
// encoding == "utf-8"

   
// we didn't keep track of our previous traversal, so let's start again
   
// we can match nodes by name, skipping the xml declaration entirely
    xml_node
<>* cur_node = doc.first_node("rootnode");
   
string rootnode_type = cur_node->first_attribute("type")->value();
   
// rootnode_type == "example"

   
// go straight to the first evendeepernode
    cur_node
= cur_node->first_node("childnode")->first_node("evendeepernode");
   
string attr2 = cur_node->first_attribute("attr2")->value();
   
// attr2 == "dog"

   
// and then to the second evendeepernode
    cur_node
= cur_node->next_sibling("evendeepernode");
    attr2
= cur_node->first_attribute("attr2")->value();
   
// now attr2 == "wolf"
}

posted on 2010-08-18 02:35 楊粼波 閱讀(1250) 評論(3)  編輯 收藏 引用

評論

# re: Quick notes on how to use RapidXML 2010-08-18 20:29 dayforever

記得修改allocstring函數(shù),將最后一個字符設(shè)置為'\0',不然死很難看
記得使用前先看看對應flag的意思,不然死的很難看  回復  更多評論   

# re: Quick notes on how to use RapidXML 2010-08-18 20:30 dayforever

記得所有的value都必須是常量字符串或者是allocstring出來的,不然死的很難看  回復  更多評論   

# re: Quick notes on how to use RapidXML 2010-08-23 20:49 楊粼波

不明白……  回復  更多評論   


只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            avtt综合网| 欧美一区二区三区在线播放| 亚洲一区网站| 亚洲午夜免费福利视频| 一区二区三区成人精品| 夜夜夜久久久| 午夜免费日韩视频| 久久免费少妇高潮久久精品99| 欧美在线免费视频| 久久久精品日韩欧美| 免费视频最近日韩| aⅴ色国产欧美| 国产精品美腿一区在线看| 欧美视频中文在线看| 国产精品国产三级国产专播精品人 | 欧美视频一区二区三区在线观看 | 性欧美大战久久久久久久免费观看 | 欧美成人一区在线| 亚洲国产精品尤物yw在线观看| 久久国产毛片| 亚洲成人自拍视频| 亚洲在线观看免费视频| 久久九九精品| 国产精品va| 亚洲黄色av一区| 亚洲欧美伊人| 欧美成人激情视频免费观看| 99国产精品自拍| 久久久久久久综合日本| 欧美视频一区二区| 亚洲二区在线| 午夜精品影院| 亚洲黄色影院| 久久精品女人天堂| 欧美视频网址| 日韩视频一区二区三区在线播放| 欧美一区二视频在线免费观看| 欧美成人精品三级在线观看| 亚洲一区二区三区在线播放| 欧美激情按摩在线| 精品不卡一区| 欧美主播一区二区三区美女 久久精品人| 免费高清在线视频一区·| 亚洲视频导航| 欧美aaa级| 黄色亚洲免费| 欧美一区二视频| 一本久久a久久精品亚洲| 美女爽到呻吟久久久久| 国内在线观看一区二区三区| 午夜欧美精品| 在线亚洲美日韩| 欧美极品在线观看| 在线免费观看一区二区三区| 久久久久久亚洲精品杨幂换脸 | 一区二区三区日韩| 香蕉免费一区二区三区在线观看| 欧美激情第8页| 久久九九99| 国产视频欧美| 欧美中文字幕视频在线观看| 一区二区三区视频在线| 欧美另类99xxxxx| 日韩视频在线一区二区| 亚洲大胆人体视频| 鲁大师影院一区二区三区| 狠狠色狠狠色综合日日五| 久久久久91| 久久久久国产成人精品亚洲午夜| 国产一级精品aaaaa看| 久久精品国产91精品亚洲| 午夜国产精品影院在线观看| 国产精品一区二区在线观看网站| 亚洲欧美久久| 欧美在线free| 亚洲国产成人精品女人久久久| 亚洲综合国产激情另类一区| 亚洲免费成人av电影| 欧美吻胸吃奶大尺度电影| 午夜精品久久99蜜桃的功能介绍| 亚洲综合精品| 极品中文字幕一区| 亚洲国产裸拍裸体视频在线观看乱了| 欧美成ee人免费视频| 在线亚洲伦理| 亚欧美中日韩视频| 亚洲国产成人精品女人久久久| 亚洲国产一区二区三区在线播 | 国产专区精品视频| 久久人人九九| 欧美大秀在线观看| 午夜精品久久久久久久久| 欧美在线你懂的| 亚洲福利国产| 在线亚洲欧美视频| 精品成人国产| 日韩一二在线观看| 精品成人国产在线观看男人呻吟| 欧美激情久久久久| 国产精品美女主播| 欧美福利一区二区| 国产精品户外野外| 欧美成人免费网站| 国产精品豆花视频| 欧美高清视频在线| 国产精品一区久久| 亚洲人成人一区二区在线观看| 国产日韩欧美一区二区| 亚洲国产一区二区三区a毛片| 欧美日韩国产999| 久久婷婷一区| 国产精品久久看| 亚洲国产一二三| 韩国一区二区三区在线观看| 日韩午夜免费视频| 亚洲国产一二三| 99一区二区| 蜜月aⅴ免费一区二区三区| 欧美日韩亚洲网| 美日韩精品视频| 国产精品素人视频| 日韩视频三区| 亚洲国产乱码最新视频 | 亚洲激情婷婷| 欧美精品www| 欧美国产精品v| 狠狠噜噜久久| 欧美一区二区三区视频免费| 亚洲一区一卡| 欧美日韩另类视频| 亚洲欧洲综合另类| 亚洲风情在线资源站| 久久蜜桃精品| 蜜臀99久久精品久久久久久软件 | 一区二区国产日产| 欧美激情网站在线观看| 欧美高清在线一区二区| 亚洲电影在线看| 久久在线免费观看视频| 老司机67194精品线观看| 国产一级一区二区| 久久久精彩视频| 久久综合伊人77777| 国语自产精品视频在线看| 欧美在线视频网站| 久久九九热re6这里有精品| 国产欧美一区二区精品性| 亚洲欧美日本国产有色| 欧美怡红院视频| 国产亚洲欧美日韩在线一区| 欧美在线视频a| 欧美成人精品在线| 99在线热播精品免费| 欧美区在线观看| 国产精品99久久久久久www| 亚洲欧美日本在线| 国产欧美一区二区精品婷婷| 欧美一区二区网站| 欧美成人午夜激情| 亚洲美女视频| 国产精品免费aⅴ片在线观看| 亚洲女人天堂成人av在线| 久久精品日韩欧美| 亚洲国产日韩在线一区模特| 欧美精品一区二区视频| 亚洲影院一区| 欧美成人国产va精品日本一级| 日韩视频在线一区二区| 国产精品有限公司| 久久综合图片| 亚洲免费电影在线| 久久精品中文字幕一区| 日韩午夜电影| 国产欧美一区二区三区久久| 久久精品人人做人人爽电影蜜月 | 亚洲一区二区三区影院| 国产小视频国产精品| 牛牛影视久久网| 午夜国产精品视频| 亚洲日本黄色| 久久综合伊人77777| 久久国产一二区| 亚洲免费成人av| 国产精品福利av| 欧美成人午夜激情视频| 欧美在线播放一区二区| 一区二区不卡在线视频 午夜欧美不卡在| 久久久天天操| 亚洲欧美激情视频| 日韩一二三在线视频播| 伊人久久婷婷| 国产亚洲欧美日韩在线一区| 欧美色视频在线| 欧美激情一区二区三区| 久久另类ts人妖一区二区| 亚洲欧美在线另类| 亚洲一区二区在线观看视频| 亚洲最新在线| 99这里有精品| 亚洲美女视频|