fixes recursion in getElement{ById,sByTagName}

Fixes getElementById and getElementsByTagName to work no matter how deep the
target element(s) might be in the XML tree.