XML in core

David Calinski <[email protected]> Fri, 7 Nov 2003 06:59:16 +0100
Newsgroups gmane.comp.tools.memaid.devel
Message-ID <[email protected]>
Hi all,

Finally I have some time for MemAid.

About XML: I was looking for a XML parser in C, on MIT/BSD license.
Sure, there are at least two such parsers ("expat" and XML parser from GNOME), 
pretty good. Problem with them is: they are pretty huge (a lot of code) 
compared to MemAid core. :-/
And I would like to avoid using external libraries (but basically I though 
about just incorporating parser code to MemAid core), I simply don't want 
MemAid to have any dependencies, as much as this is possible without 
sacrificing anything.

Well, so I have written my own code loading data from XML file.
I bet it's not TheRight[tm] approach to reading XML, but it's *very* simple, 
so doesn't bloat code a lot, and with some tweaking - should be fast and make 
some basic validation on the fly.
(please let me know if I omitted something and memaid needs a real parser)

Format is: (it's proposed format, I would like to hear your feedback)

<memaid_data core_version="5" time_of_start="1068183140">

<item tm_t_rpt="2" stm_t_rpt="0" l_ivl="0" rl_l_ivl="0" ivl="2" rp="0" gr="3">
<id>
<![CDATA[id string]]>
</id>
<question>
<![CDATA[question here]]>
</question>
<answer>
<![CDATA[answer here]]>
</answer>
</item>


I was based it on Klemens propose, and Bruno suggestion about short variables. 
(e.g. "gr" instead of "grade"). Is it ok?

Ah, I added <id> field.
Should <id> field be protected with <![CDATA[ as well, or maybe it's 
exaggeration? Well, never know who and what for will use id field in the 
future.

Changes (added load_xml() and save_xml() functions) are not yet committed to 
CVS, but available here:
http://orcio.cjb.net/~neodave/memaid/src (I didn't test it yet, just coded it, 
and it's rough yet.)

If something is not ok, or something... just let me know, I'm not a XML 
expert, hopefully you will correct me. :)

DC



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/