From: Adam Dickmeiss Date: Wed, 8 Jun 2011 14:29:36 +0000 (+0200) Subject: get_{bool,int} reads childen node X-Git-Tag: v1.2.6~22 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=f8bcd30533d438d7e2151f742a70d4c5313cc9ec;p=metaproxy-moved-to-github.git get_{bool,int} reads childen node --- diff --git a/src/xmlutil.cpp b/src/xmlutil.cpp index 7e3db5a..288096f 100644 --- a/src/xmlutil.cpp +++ b/src/xmlutil.cpp @@ -45,9 +45,12 @@ std::string mp_xml::get_text(const xmlNode *ptr) bool mp_xml::get_bool(const xmlNode *ptr, bool default_value) { + if (ptr && ptr->type != XML_TEXT_NODE) + ptr = ptr->children; if (ptr && ptr->type == XML_TEXT_NODE && ptr->content) { - if (!strcmp((const char *) ptr->content, "true")) + if (!strcmp((const char *) ptr->content, "true") + || !strcmp((const char *) ptr->content, "1")) return true; else return false; @@ -56,7 +59,9 @@ bool mp_xml::get_bool(const xmlNode *ptr, bool default_value) } int mp_xml::get_int(const xmlNode *ptr, int default_value) -{ +{ + if (ptr && ptr->type != XML_TEXT_NODE) + ptr = ptr->children; if (ptr && ptr->type == XML_TEXT_NODE && ptr->content) { return atoi((const char *) ptr->content);