GPX-Visualizer/Xml.cpp

27 lines
547 B
C++

#include "Xml.h"
using namespace rapidxml;
xml_node<>* recursive_find_next_node(xml_node<> *node, const std::string &node_name)
{
if(!node)
return nullptr;
// go through each sibling node...
for(; node; node = node->next_sibling())
{
if(node->name() == node_name)
return node;
// first make sure none of the children nodes have this name, too.
if(node->first_node() != nullptr)
{
auto child_node = recursive_find_next_node(node->first_node(), node_name);
if(child_node)
return child_node;
}
}
return nullptr;
}