the simple solution is that you could check resultset before you append your node and if it's not null or " " then append it .