Archive for June, 2011

ZSocket Library – a thin wrapper around BSD socket.

Leave a Comment

PUGI – A simple XML parser api from google labs…

usage example:
=============

#include “pugixml.hpp”

int _tmain(int argc, _TCHAR* argv[])
{
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_file(“temp.xml”);

for (pugi::xml_node user = doc.child(L”logins”).child(L”user”); user; user = user.next_sibling(L”user”))
{
//std::cout << “Tool ” << tool.attribute(“Filename”).value();
//std::cout << “: AllowRemote ” << tool.attribute(“AllowRemote”).as_bool();
//std::cout << “, Timeout ” << tool.attribute(“Timeout”).as_int();
//std::cout << “, Description ‘” << tool.child_value(“Description”) << “‘\n”;
std::wcout << L”\n” << user.child_value(L”name”) << L” [” << user.child_value(L”pwd”) << L”]”;
}

return 0;
}

————————————————————————————————————————————————

Following code will create xml nodes within node <logins></logins>

<user>

    <uname>username</uname>

    <pwd>48729038787AB789DE3FF</pwd>

    <display>First Name Last Name</display>

</user>

pugi::xml_node node_user = doc.child(L”logins”).append_child(L”user”);

if(is_admin == true){
node_user.append_attribute(L”is_admin”) = L”1″;
}

pugi::xml_node node_uname = node_user.append_child(L”uname”).append_child(pugi::node_pcdata);
node_uname.set_value(s_user_name);

pugi::xml_node node_pwd = node_user.append_child(L”pwd”).append_child(pugi::node_pcdata);
node_pwd.set_value(szHashPasswdHex);

pugi::xml_node node_display = node_user.append_child(L”display”).append_child(pugi::node_pcdata);
node_display.set_value(s_display_name);

————————————————————————————————————————————————

Leave a Comment