I'm looking for some help in making a routine that returns the element type, all class
es, and an id
if there is one, and the child elements. For instance, if I have
<div class="someClass someOtherClass" id="someID"><p>Here's a line</p><p>Here's another line</p></p></div>
then I'm processing the string
"div class=\"someClass someOtherClass\" id=\"someID\"<p>Here's a line</p><p>Here's another line</p></p></div>"
and wanting to get the element div
, the classes someClass
, someOtherClass
, the id someID
, and the two p
elements that are the children. So the setup looks like
node * process_tag(const std::string & outerHTML)
{
node * retNode = new node;
// ...
return retNode;
}
where a node
is defined by
struct node
{
std::string element_type;
std::vector<std::string> class_list;
std::string iden;
std::vector<node*> children;
};
Is there an easy way to do this or am I going to stay up late trying to figure it out tonight?