To cover all the nodes in this file, you need to look at each node's children and its siblings. You seem to understand that.
Your recursion approach is a workable choice for getting to the children. It seems to be working. Each recursive call to loop
goes one level deeper into the children. (Whoever told you to use a "queue" possibly meant "stack" ... and recursion uses a stack implicitly. The call stack.)
It's the siblings that are being missed. And since recursion is being used to go deeper into the XML tree, this probably isn't going to be solved with more recursion.
Look at this code part of your code:
xml_node<> * child = species->first_node("species");
if(child != 0)
{
cout << child->first_node("name")->value() << endl;
This is where you are finding the first sibling, such as "swordfish"
.
Try changing that if
statement into a loop, so the contained logic is performed on all the siblings instead of just the first one.