I have an xml that sometimes comes empty node image, but as I can not control and is not nor as undefined, or as null or as''.
var arrImages = xml.documentElement.getElementsByTagName('Image');
if (arrImages == undefined || arrImages == '' || arrImages == null)
alert ('Undefined');
else
alert (arrImages.item(0).text)
Any solution??
2 Answers
Try using a try/catch instead.
eg: http://www.w3schools.com/js/js_try_catch.asp
Hi Raul,
If you have an xml like
<root attribute='a'></root>and if you get empty as response
<root /> here you can check if(root.hasAttribute('attribute')) { // true }Hope this will solve your prob.
Your Answer
Think you can help? Login to answer this question!