diff --git a/include/assimp/XmlParser.h b/include/assimp/XmlParser.h index bc827b0f2..2ce1ebcd2 100644 --- a/include/assimp/XmlParser.h +++ b/include/assimp/XmlParser.h @@ -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); } } diff --git a/test/unit/Common/utXmlParser.cpp b/test/unit/Common/utXmlParser.cpp index 8973dee42..f2892208e 100644 --- a/test/unit/Common/utXmlParser.cpp +++ b/test/unit/Common/utXmlParser.cpp @@ -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()); + } }