www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - (Another) XML Module Candidate

I've built an XML parsing library in the last few months as an 
experimentation of D2 template capabilities and as an attempt to work 
with ranges. The idea is that if successful enough it could become part 
of Phobos 2. You can use it to do tokenization as an event parser or a 
pull parser or a mix of the two; and there's a small DOM built on top 
of the tokenizer.

It didn't turn out as elegant as I would have hoped but it works and is 
probably  as fast as Tango's pull parser (when used as a tokenizer) but 
I haven't tested. The library certainly is incomplete: well-formness 
checking is partial, it doesn't support documents with an internal 
subset in the Doctype, the DOM that comes with it is very crude and the 
tokenizer will need some small adaptations to work with arbitrary input 
ranges (currently it accepts strings only, but reads them mostly in a 
range-like way).

I don't have much time to improve it right now, so if someone else 
wants to fix the remaining issues and add more polish perhaps it could 
be a great addition to the D standard library.

Here's the current API docs:

And here's the code:

(It's not mentioned anywhere, but I'm willing to put this code under 
the boost license.)

Michel Fortin
michel.fortin michelf.com
Oct 20 2009