Line 1:
Line 1:
+
+
== Loading from an XML With default values to fall back on ==
+
I found the following code usefull, please not using this demands you check for NULL yourself!
I found the following code usefull, please not using this demands you check for NULL yourself!
This should not pose a problem, as Name is most likely a constant string.
This should not pose a problem, as Name is most likely a constant string.
Line 21:
Line 24:
//watch out for unsafe code!
//watch out for unsafe code!
//USE WITH CAUTION!!!
//USE WITH CAUTION!!!
+
// use strcpy if you want to keep the string (the result is a char[] that is replaced or freed)
const char * mxml_GetString(mxml_node_s * node, const char * name, char * default_value)
const char * mxml_GetString(mxml_node_s * node, const char * name, char * default_value)
{
{
Line 31:
Line 35:
}
}
</pre>
</pre>
+
+
[[User:Freezy|Freezy]] 09:23, 20 August 2009 (UTC)