2013-10-23 38 views
0

我遇到了一些與rapidxml有關的問題。當我編譯我的代碼沒有啓動標籤included..any和所有幫助將不勝感激Rapidxml和開始標記

int main(){ 


    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, "root"); 
     root->append_attribute(doc.allocate_attribute("")); 
        doc.append_node(root); 
       // child/sibling node 
     xml_node<>* sibling0 = doc.allocate_node(node_element, "old"); 
     root->append_node(sibling0); 
     xml_node<>* sibling = doc.allocate_node(node_element,"boy"); 
     root->append_node(sibling); 
       std::string xmlstring; 
     print(back_inserter(xmlstring), doc); 
     cout << xmlstring << endl;} 
+0

結束對你什麼輸出? – Roddy

回答

0

除了必要的#includes,和失蹤using namespace rapidxml;您的代碼編譯爲我運行正常。

的xmlString包含此:

<?xml version="1.0" encoding="utf-8"?> 
<root =""> 
    <old/> 
    <boy/> 
</root> 

因爲oldboy沒有內容,他們使用XML空元素標籤,<tagname/>而不是開始,像<tagname></tagname>

+0

非常感謝!羅迪 – user2911641