Talk:Mini-XML: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Answer |
||
Line 1: | Line 1: | ||
== Loading from an XML With default values to fall back on == | == Loading from an XML With default values to fall back on == | ||
Line 19: | Line 6: | ||
Loading settings from a XML with these is easier, as you don't have to check and correct manually in the loading code. | Loading settings from a XML with these is easier, as you don't have to check and correct manually in the loading code. | ||
< | <source lang="c"> | ||
#include <mxml.h> | #include <mxml.h> | ||
Line 46: | Line 33: | ||
return default_value; | return default_value; | ||
} | } | ||
</ | </source> | ||
[[User:Freezy|Freezy]] 09:23, 20 August 2009 (UTC) | |||
[[User: | |||
== Problem with devkitPro r18 == | |||
With the devkitPro r18, I get the errors: | |||
<pre> | |||
1>linking ... boot.elf | |||
1>c:/devkitPro/libogc/lib/wii\libmxml.a(mxml-file.o): In function `mxml_get_entity': | |||
1>/home/ew562c/Dev/wiichat/Client/mxml-2.5/mxml-file.c(1423): undefined reference to `__ctype_ptr' | |||
1>/home/ew562c/Dev/wiichat/Client/mxml-2.5/mxml-file.c(1423): undefined reference to `__ctype_ptr' | |||
1>c:/devkitPro/libogc/lib/wii\libmxml.a(mxml-string.o): In function `_mxml_vsnprintf': | |||
1>/home/ew562c/Dev/wiichat/Client/mxml-2.5/mxml-string.c(209): undefined reference to `__ctype_ptr' | |||
1>/home/ew562c/Dev/wiichat/Client/mxml-2.5/mxml-string.c(177): undefined reference to `__ctype_ptr' | |||
1>/home/ew562c/Dev/wiichat/Client/mxml-2.5/mxml-string.c(209): undefined reference to `__ctype_ptr' | |||
1>collect2: ld returned 1 exit status | |||
</pre>{{unsigned|Freezy}} | |||
: Are you using version 2.6, the download is available on this [[Mini-XML|page]]? I guess not, by seeing your message. So install 2.6 and it should work :) --[[User:Crayon|Crayon]] ([[User talk:Crayon|talk]]) 13:34, 17 October 2009 (UTC) |
Latest revision as of 15:34, 17 October 2009
Loading from an XML With default values to fall back on
I found the following code usefull, please note: using this demands you check for NULL yourself! This should not pose a problem, as Name is most likely a constant string (and node was most likely already checked).
Loading settings from a XML with these is easier, as you don't have to check and correct manually in the loading code.
#include <mxml.h>
//watch out for unsafe code!
//USE WITH CAUTION!!!
int mxml_GetInt(mxml_node_s * node, const char * name, int default_value)
{
const char * value = mxmlElementGetAttr(node,name);
if(value)
{
return atoi(value);
}
return default_value;
}
//watch out for unsafe code!
//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 * value = mxmlElementGetAttr(node,name);
if(value)
{
return value;
}
return default_value;
}
Freezy 09:23, 20 August 2009 (UTC)
Problem with devkitPro r18
With the devkitPro r18, I get the errors:
1>linking ... boot.elf 1>c:/devkitPro/libogc/lib/wii\libmxml.a(mxml-file.o): In function `mxml_get_entity': 1>/home/ew562c/Dev/wiichat/Client/mxml-2.5/mxml-file.c(1423): undefined reference to `__ctype_ptr' 1>/home/ew562c/Dev/wiichat/Client/mxml-2.5/mxml-file.c(1423): undefined reference to `__ctype_ptr' 1>c:/devkitPro/libogc/lib/wii\libmxml.a(mxml-string.o): In function `_mxml_vsnprintf': 1>/home/ew562c/Dev/wiichat/Client/mxml-2.5/mxml-string.c(209): undefined reference to `__ctype_ptr' 1>/home/ew562c/Dev/wiichat/Client/mxml-2.5/mxml-string.c(177): undefined reference to `__ctype_ptr' 1>/home/ew562c/Dev/wiichat/Client/mxml-2.5/mxml-string.c(209): undefined reference to `__ctype_ptr' 1>collect2: ld returned 1 exit status
—Preceding unsigned comment added by Freezy (talk • contribs)