
As well as a harder-to-implement direction. Having to make a struct for every tag you implement seems a little user-unfriendly. For a constrained format (like SVG) I could agree, but I think for Boost.XML library, there should be easy naming.
Splitting the difference (or so I hope) between easy trees/expressiveness and standard syntax, how about something like this?
root.push_front ( tag("Article Info", (title ? (comment("This title was moved"), title) : NULL) (tag("author", (tag("firstname", "Joe")) (tag("surname", "Random")) )) ) );
I find it relay hard to read and I'm missing the typesafety. Nothing prevents you to put tag("firstname", "Joe") in place of article info tag! You are forced to validate it at runtime. Phils suggestion is more typesafe: articleinfo ai; { if (title) ai.push_back(comment("This title was moved")); author a; { a.push_back(firstname("Joe")); a.push_back(surname("Random")); ai.push_back(a); } root.push_back(ai); } I would like to see translating xsd (xml schemas) to c++ classes (but this could be a further improvment). A good idea would be providing an iterator which can be used traverse the xml-tree. Oliver