Take the 2-minute tour ×

I'm working on the beginnings of porting my php based OOP web framework to the d language and I'm having some trouble figuring out if it is safe to rely on phobos' std.xml classes to read xml from files and/or streams. There seems to be quite a bit of chatter on replacing std.xml, so much even that I'm considering rolling my own 100% d xml parser.

Since this is very much a hobby project, I don't mind designing my own wheels all that much, it'd be a fun exercise and give me a chance to learn more about the language faster. On the other hand, If I don't have to roll my own, I could potentially be up and running much faster.

I'll need to support basically a nearly full xml 1.0 spec, most notably I'll need xml namespaces and xincludes to work properly. I'd also want my API to be more or less consistent with php's DOMDocument, c#'s System.Xml.XmlDocument and javascript's DOM implementation. especially that last bit seems missing from phobos. Also phobos still seems to be at least somewhat in flux and I'm not up to speed on the level of flux it is in.

The big question therefor is: is it safe to rely on the parsing tools in phobos' std.xml being able to provide the lions share of my requirements, or should I write something from the ground up in my own library to be safe?

When answering please do consider my requirements:

  1. full xmlns support
  2. xincludes
  3. should be able to read from file, stream or string
  4. needs to be as similar as possible to the big DOM implementations and spec
share|improve this question

2 Answers 2

up vote 4 down vote accepted

Don't use std.xml. Aside from the fact that it is a terrible library, it's going to be replaced at some point.

share|improve this answer
That's what I'm worried about. Can you elaborate on that though? who said so? (Walter Bright or Andrei Alexandrescu saying that would carry a lot of weight but...) –  Kris Oct 28 '11 at 6:41
I've talked to Andrei (on IRC), and he confirmed that std.xml is going the way of the dodo. Can't give you a timeline though. –  Bernard Oct 28 '11 at 7:34
awesome info, thanks! –  Kris Oct 28 '11 at 9:09
A replacement is already in the works, but when it's ready depends on when the person implementing it finishes it. After that, it'll be formally reviewed in the Digitalmars.D newsgroup, and once it's been reviewed and voted in, it'll be put into Phobos. But there's no set date for any of that. Unfortunately, it's just going take however long it takes. I expect that it'll be at least several months though. –  Jonathan M Davis Oct 28 '11 at 17:03
There's at least one std.xml replacement already in the works (try searching for std.xml2 on the D discussion lists; I don't have a link handy). Personally, I've had much success wrapping libxml2 and libxslt -- I don't have a full binding, I just did the parts I needed. Just saying, starting your own project may not be the most effective solution. –  gmfawcett Oct 28 '11 at 20:03

std.xml is going to be replaced. But there a DOM XML parser for D2, perhaps you should try it. It's in github (dom.d) : https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff

share|improve this answer

Your Answer


