RouterFleXML now reads XML simple config and make proper runtime
[metaproxy-moved-to-github.git] / src / xmlutil.cpp
1 /* $Id: xmlutil.cpp,v 1.1 2006-01-09 13:43:59 adam Exp $
2    Copyright (c) 2005, Index Data.
3
4 %LICENSE%
5  */
6
7 #include "xmlutil.hpp"
8
9 std::string yp2::xml::get_text(const xmlNode *ptr)
10 {
11     std::string c;
12     for (ptr = ptr->children; ptr; ptr = ptr->next)
13         if (ptr->type == XML_TEXT_NODE)
14             c += std::string((const char *) (ptr->content));
15     return c;
16 }
17
18
19 bool yp2::xml::is_element(const xmlNode *ptr, 
20                           const std::string &ns,
21                           const std::string &name)
22 {
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))
26         return true;
27     return false;
28 }
29
30 bool yp2::xml::is_element_yp2(const xmlNode *ptr, 
31                               const std::string &name)
32 {
33     return yp2::xml::is_element(ptr, "http://indexdata.dk/yp2/config/1", name);
34 }
35
36
37 /*
38  * Local variables:
39  * c-basic-offset: 4
40  * indent-tabs-mode: nil
41  * c-file-style: "stroustrup"
42  * End:
43  * vim: shiftwidth=4 tabstop=8 expandtab
44  */