html - JavaScript error with XML when trying to read empty node -
    i trying render catalog xml document , works, although when trying show default image if there no image present in xml node, disables parent node therefore forcing not show of , reads me error in console saying:      uncaught typeerror: cannot read property 'getelementsbytagname' of   undefined    which pointing part of code:      if (records[i].getelementsbytagname("image")[0].childnodes.length > 0)   {    so question in code below error causing not load xml node?   ps: if needs more of code please let me know, , happy post it.   for (var = fromitem; < nextmaxitem; i++) {             if (records[i].getelementsbytagname("image")[0].childnodes.length > 0) {                  xmlcontent += '<article class="post ' + records[i].getelementsbytagname("category")[0].childnodes[0].nodevalue + '" id="">'                     + '<div class="col-sm-4 col-lg-4 col-md-4"><div class=...