Check for empty elements before creating xml nodes