pea
developer
Hi all,
I have developed a very simple to use XML parsing library for the GP32 over the last few days. It uses Mr.Mirkos SDK. It is very handy for doing things like loading game data (scores, options, game levels etc).
If anybody is interested, I will release a copy of it for beta testing on my site. I would like to iron out the bugs (if any ) before I release it fully.
Supports basic structuring:
It currently has functions to:
load and parse from textfile
parse from memory
add attributes to nodes on the fly
add new nodes as siblings or children on the fly
What it doesn't have YET are:
functions to save xml
functions to remove nodes
functions to reorder nodes
What it doesn't have that it will probably never have are:
Support for declaration tags <?something>
Support for DTD tags <!something>
Support for substitution/variables (whatever they are called)
Comments
Simple example:
More examples:
I have developed a very simple to use XML parsing library for the GP32 over the last few days. It uses Mr.Mirkos SDK. It is very handy for doing things like loading game data (scores, options, game levels etc).
If anybody is interested, I will release a copy of it for beta testing on my site. I would like to iron out the bugs (if any ) before I release it fully.
Supports basic structuring:
Code:
<classroom>
<blackboard width=21cm height="38 cm">
This is what is written on the blackboard, and becomes a
text node which is a child of blackboard. It supports
any type 'of string' which may contains "<tags>" which
are ignored because they are in the string.
</blackboard>
<desks row='1'>
<pupil>John</pupil>
<pupil>Mary</pupil>
<pupil>Sally</pupil>
</desks>
<desks row='2'>
<pupil>Thomas</pupil>
<pupil>Henry</pupil>
<pupil>Jane</pupil>
</desks>
</classroom>
It currently has functions to:
load and parse from textfile
parse from memory
add attributes to nodes on the fly
add new nodes as siblings or children on the fly
What it doesn't have YET are:
functions to save xml
functions to remove nodes
functions to reorder nodes
What it doesn't have that it will probably never have are:
Support for declaration tags <?something>
Support for DTD tags <!something>
Support for substitution/variables (whatever they are called)
Comments
Simple example:
Code:
#include "gp32.h"
#include "gp_xml.h"
int main() {
tGP_XMLElement *xml;
int res, line, col;
// Set CPU speed
gp_setCpuspeed(66);
// Parse XML file
xml = gp_xmlLoad("dev0:\\GPMM\\test.xml", &line, &col, &res);
// res returns non-zero on fail
// if fail, line and col contain the character in the xml that caused the error
if (xml){
// Free XML file
gp_xmlFree( xml, 1 );
}
// Reset GP
gp_Reset();
}
More examples:
Code:
// Stepping through all sibling nodes
while(xml){
sprintf( buffer, "Next sibling node is:%s", xml->name );
xml = xml->next;
}
// Stepping through all child nodes of a node
if (xml->children){
xml = xml->children;
while(xml){
sprintf( buffer, "Next child node is:%s", xml->name );
xml = xml->children;
}
}
// Stepping through all attributes of a node
attribute = xml->attributes;
while(attribute){
sprintf( buffer, "Next attribute: %s = %s", attribute->name, attribute->value );
attribute = attribute->next;
}