Hi I'm using pugixml to process xml documents. I iterate through nodes using this construction
pugi::xml_node tools = doc.child("settings");
//[code_traverse_iter
for (pugi::xml_node_iterator it = tools.begin(); it != tools.end(); ++it)
{
//std::cout << "Tool:";
cout <<it->name();
}
the problem is that it->name() returns pugi::char_t* and I need to convert it into std::string. Is it possible ?? I can't find any information on pugixml website
According to the manual,
pugi::char_t
is eitherchar
orwchar_t
, depending on your library configuration. This is so that you can switch between single bytes (ASCII or UTF-8) and double bytes (usually UTF-16/32).This means you don't need to change it to anything. However, if you're using the
wchar_t*
variant, you will have to use the matching stream object:And, since you asked, to construct a
std::string
orstd::wstring
from it:Or, for always a
std::string
(this is rarely what you want!):Hope this helps.
Source: A cursory glance at the "pugixml" documentation.