The task is to find how many times "Africa" appears in the data of the <location> tag throughout the document.
I wonder how fast grep/strstr compares, since they can run at "faster than memcpy" speeds, which means dozens of GB/s on any relatively recent machine. I know it's not the "pedantically correct" way to to do it, but in practice it works well. Only mode-escapes like CDATA can break the fact that XML tags otherwise cannot occur as substrings, so a substring match can work otherwise. This is especially true for JSON which doesn't have such escapes.
Of course not using XML may gain more than an order of magnitude in speed, so if you have the chance to control both ends and get rid of XML in favour of a simpler binary protocol, I strongly recommend advocating for it.
I wonder how fast grep/strstr compares, since they can run at "faster than memcpy" speeds, which means dozens of GB/s on any relatively recent machine. I know it's not the "pedantically correct" way to to do it, but in practice it works well. Only mode-escapes like CDATA can break the fact that XML tags otherwise cannot occur as substrings, so a substring match can work otherwise. This is especially true for JSON which doesn't have such escapes.
Of course not using XML may gain more than an order of magnitude in speed, so if you have the chance to control both ends and get rid of XML in favour of a simpler binary protocol, I strongly recommend advocating for it.