The original idea of making an if-else chain was good, but your change was converting the originally unnatural checks sequence into another unnatural checks sequence. I submitted another PR which puts checks in a more optimistic order https://github.com/leethomason/tinyxml2/pull/260 Thanks for the idea.