Boost logo

Boost Users :

Subject: [Boost-users] [spirit] qi xml parser
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2014-06-30 16:14:10


I am building out a general use xml parser including attributes,
arbitrary number of elements, and so on.

So far so good, makes sense parsing names and so forth. However, how
do you handle element content? Which could either be a string, or zero
or more other elements (basically of the same rule as the enclosing
element rule).

It would seem you need a terminus, the empty element tag. In such a
way that populates the parent (initial) element, and its children (of
the same element kind).

I'll be adapting structs to capture the results. I am also using a
couple of helpful references, for instance:

Also not sure quite how to capture the adapted parts at strategic rule

My domain model will look something like this, keeping it simple as possible:

struct xattribute {
    std::string name;
    std::string value;

typedef std::vector<xattribute> xattribute_vector;

struct xelement;

typedef std::vector<xelement> xelement_vector;

struct xelement {
    std::string name;
    std::string content;
    xattribute_vector attributes;
    xelement_vector children;


Best regards,

Michael Powell

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at