Revert "improve performance in simplexml"

This reverts commit ea535b8292e8fdf271762e9a9bc949c64c40fc7a.

Closes #3963.
Closes #4119.
add additional empty() check