1 /* $Id: xmlutil.cpp,v 1.2 2006-01-11 11:51:50 adam Exp $
2 Copyright (c) 2005, Index Data.
9 std::string yp2::xml::get_text(const xmlNode *ptr)
12 for (ptr = ptr->children; ptr; ptr = ptr->next)
13 if (ptr->type == XML_TEXT_NODE)
14 c += std::string((const char *) (ptr->content));
19 bool yp2::xml::is_element(const xmlNode *ptr,
20 const std::string &ns,
21 const std::string &name)
23 if (ptr && ptr->type == XML_ELEMENT_NODE && ptr->ns && ptr->ns->href
24 && !xmlStrcmp(BAD_CAST ns.c_str(), ptr->ns->href)
25 && !xmlStrcmp(BAD_CAST name.c_str(), ptr->name))
30 bool yp2::xml::is_element_yp2(const xmlNode *ptr,
31 const std::string &name)
33 return yp2::xml::is_element(ptr, "http://indexdata.dk/yp2/config/1", name);
36 std::string yp2::xml::get_route(const xmlNode *node)
38 std::string route_value;
41 const struct _xmlAttr *attr;
42 for (attr = node->properties; attr; attr = attr->next)
44 std::string name = std::string((const char *) attr->name);
47 if (attr->children && attr->children->type == XML_TEXT_NODE)
48 value = std::string((const char *)attr->children->content);
53 throw XMLError("Only attribute route allowed"
54 " in " + std::string((const char *)node->name)
55 + " element. Got " + std::string(name));
64 * indent-tabs-mode: nil
65 * c-file-style: "stroustrup"
67 * vim: shiftwidth=4 tabstop=8 expandtab