2016-04-17 51 views
0

它是如何使用where()函數的?rapidxml使用where()函數

using namespace rapidxml; 
    xml_document<> doc; 
    std:string xmlfile = "test.xml"; 
    std::ifstream file (xmlfile); 
    std::stringstream buffer; 
    buffer << file.rdbuf (); 
    file.close (); 
    std::string content (buffer.str ()); 

    try 
    { 
     doc.parse<0> (&content [ 0 ]); 
    } 

    catch (rapidxml::parse_error& e) 
    { 
     std::cout << "Parsing error: " << e.what () << "\n"; 
     //const Ch* e.where (); 
    } 

得到了什麼(),但正在尋找某種指標從哪裏()像打破了XML的最後一個節點?

回答

0

要使用RapidXml where() metohd,嘗試這樣的事情:

std::cout << e.where<char>(); 

因爲where指針返回到原始XML數據,這是一個模板函數。您可以使用返回的指針和原始數據通過計算換行符來確定行和列的位置。