
David Abrahams wrote:
I find XML horrible to read, however I find most of the procedural code I've seen for manipulating it even more horrible.
I would like to see a more declarative syntax for much of this stuff.
element_ptr info = root->insert_element(root->begin_children(), "articleinfo"); if (title) { info->insert(info->begin_children(), title); info->insert_comment(info->begin_children(), "This title was moved"); } element_ptr author = info->append_element("author"); element_ptr firstname = author->append_element("firstname"); firstname->set_content("Joe"); element_ptr surname = author->append_element("surname"); surname->set_content("Random");
could be something like:
root.push_front( tag("articleinfo")[ title ? (comment("This title was moved"), title) : NULL , tag("author")[ tag("firstname")["Joe"], tag("surname")["Random"] ] ] )
Interesting. It doesn't look a lot like raw XML but it certainly integrates better into C++.