diff options
Diffstat (limited to 'src/xml-parser.c')
| -rw-r--r-- | src/xml-parser.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/xml-parser.c b/src/xml-parser.c index 84cc204..9f95cf3 100644 --- a/src/xml-parser.c +++ b/src/xml-parser.c @@ -225,6 +225,24 @@ xml_file_get_node_attribute_boolean (TXMLFile *file, const gchar *x_path, const return b; } +double +xml_file_get_node_attribute_double (TXMLFile *file, const gchar *x_path, const gchar *attr, const double _default) +{ + gchar *s; + double d; + char *endptr = NULL; + + s = xml_file_get_node_attribute (file, x_path, attr); + if (s == NULL) + return _default; + + d = strtod (s, &endptr); + if (endptr != NULL && *endptr != '\0') + d = _default; + g_free (s); + return d; +} + /* * xml_file_get_node_present: existency test of the XPath node |
