|
Boost Users : |
Subject: [Boost-users] [spirit] qi xml parser
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2014-06-30 16:14:10
Hello,
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:
http://www.w3.org/TR/xml11/
http://stackoverflow.com/questions/9473843/boost-spirit-how-to-extend-xml-parsing
Also not sure quite how to capture the adapted parts at strategic rule
opportunities.
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;
};
Thanks...
Best regards,
Michael Powell
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net