If what you really want is the text inside location tags, you can find those easily with the right XPath:
doc.search('//location/text()')
If, for some reason, you actually need the location element itself, use this:
doc.search('//location/text()/..')
1
dismal_denizen
On
<location/> is semantically identical to <location></location>, and should be treated as such. To find all empty tags, just skip elements which do not have any child nodes (including text).
If what you really want is the text inside location tags, you can find those easily with the right XPath:
If, for some reason, you actually need the location element itself, use this: