XML Parser


> Has anyone came across a XML parser working on Symbian?
> Pc's have their Expat and so on, but is there any ready solution (source
> code, library or binaries) for Symbian?
> I need a parser working with XML 1.0 and newer files.

Hi Mike,

write a simple SAX parser is quite easy. I would recommend to you this article at NewLC:



Although writing an XML parser is, indeed, fairly easy, it is still a
definitely non-trivial task to get all of the details of the standard
right. And since XML is all about interoperability, any time you use
a (even ever so slightly) non-compliant parser you are looking for

There are two equally bad cases:
- you produce some non-well-formed XML and only test on your parser
which accepts it, but no-one else will
- your parser doesn't accept some well-formed XML

And to make it worse, both of these tend to first break in the field,
leaving you with a broken app and some unpleasant debugging.

Looking quickly at the code I think the parser in the article:
- would accept <elem></elem attr="x">
- and not accept <elem attr='bla'/>, since it only accepts double
quotes as attribute value delimiters
(I might be wrong in putting forward these specific cases, but
the author does state that 'it didn't need to have ...
strict syntax validation').

Plus it needs the document in a single buffer, which in my
opinion invalidates the claim 'it needed to have VERY
small runtime size and memory footprint'. (and doesn't
support different character encodings, DTDs, etc.).

So unless you are willing to spend a couple of months on it,
use an existing, tested parser.

And since James Clark is the god of SGML/XML parsing:
> btw, Expat is available on Symbian too...

Which is definitely the way to go. Making it look like SAX is trivial.
The only thing you'll have to worry about with expat is not to Leave
from your callbacks, since it doesn't have handling for Symbian in its
error-handling. Just TRAP errors, set an error flag, check it in your
'parse()' loop and Leave from there.