Skip to content

Instantly share code, notes, and snippets.

@Darker
Created December 8, 2014 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Darker/4b1ad792ff77a6688388 to your computer and use it in GitHub Desktop.
Save Darker/4b1ad792ff77a6688388 to your computer and use it in GitHub Desktop.
Get rapidxml xml_node children in std::vector
namespace rapidxml {
//I even managed to create it as a template, though I don't understand templates at all
template <class T>
vector<xml_node<T>*> xml_node_get_children(xml_node<T>* node, const char* filter = NULL) {
//This will be returned
vector<xml_node<T>*> children;
for (xml_node<T> *child = node->first_node(); child; child = child->next_sibling())
{
//If filter is ON, only tag name EXACT MATCHES are included
if(filter==NULL || strcmp(filter, child->name())==0)
children.push_back(child);
}
return children;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment