Created
December 8, 2014 22:47
-
-
Save Darker/4b1ad792ff77a6688388 to your computer and use it in GitHub Desktop.
Get rapidxml xml_node children in std::vector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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