簡體   English   中英

從xmlChar修剪\\ n \\ t不起作用

[英]trimming \n \t from xmlChar not working

#include "boost/algorithm/string/trim.hpp"
.
.
xmlChar *v = NULL;
cur = xmlDocGetRootElement(doc);
for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) {
    v =  xmlGetProp(cur, (const xmlChar *)"value");
    trim((char*)v);
    printf("%s",v);
}

該代碼無法編譯,未定義trim,我嘗試了boost :: trim,但沒有幫助。 謝謝。

boost::trim在C字符串上不起作用。 使用temp std::string對象,並將其傳遞給boost::trim

std::string tmp((char*)v);
boost::trim(tmp);
std::cout << tmp;

看: trim.hpp

::boost::algorithm命名空間中定義的函數。 所以使用::boost::algorithm::trim(...)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM