From f8bcd30533d438d7e2151f742a70d4c5313cc9ec Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 8 Jun 2011 16:29:36 +0200 Subject: [PATCH] get_{bool,int} reads childen node --- src/xmlutil.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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); -- 1.7.10.4