xml-parser: ensure that traverse-collectors are only collecting xmlnodes.

pull/2966/head
Kim Kulling 2020-09-02 21:48:58 +02:00
parent 87d2580aad
commit 0c05398602
2 changed files with 8 additions and 3 deletions

View File

@ -235,11 +235,11 @@ public:
}
void collectChildrenPreOrder( XmlNode &node ) {
if (node != mParent) {
std::string name = node.name();
if (node != mParent && node.type() == pugi::node_element) {
mNodes.push_back(node);
}
for (XmlNode currentNode = node.first_child(); currentNode; currentNode = currentNode.next_sibling()) {
for (XmlNode currentNode : node.children()) {
collectChildrenPreOrder(currentNode);
}
}

View File

@ -85,4 +85,9 @@ TEST_F(utXmlParser, parse_xml_and_traverse_test) {
bool empty = nodeIt.isEmpty();
EXPECT_FALSE(empty);
EXPECT_NE(numNodes, 0U);
XmlNode node;
while (nodeIt.getNext(node)) {
const std::string nodeName = node.name();
EXPECT_FALSE(nodeName.empty());
}
}