2014-11-03 22 views
1

所有的字符串,如果我有XML內容如下如何使用rapidxml進去<node />

<node> 
    <content> hello <b>world</b> 
      <image src="src/image.jpg"/>  
    </content>  
</node> 

我想獲得價值爲字符串,它具有內部 所有數據或讓說

string all_data = node->get_XXXX????(); 

最後all_data ==「<」內容>你好< b> world </b> \ n < image src = \「src/image.jpg \」/> \ n </content>「

回答

0

你需要print它使用rapidxml_print.hpp

功能在這裏看到。 http://rapidxml.sourceforge.net/manual.html#namespacerapidxml_1printing

// Print to string using output iterator 
std::string s; 
print(std::back_inserter(s), node, 0); 

請注意,這將有可能重新格式化空白,等周圍的標籤。如果這對你至關重要,你應該找到另一種編碼文檔的方法。

相關問題