I am trying to write a javascript function to parse a bit of the DOM tree and return a part of it to further parse. Despite stepping through the function which seems to be working fine, the return of the function shows as undefined to the calling statement. Is there a way to fix this?
from = entityfromid($(value)[0].getElementsByTagName("O1")[0].childNodes[0].childNodes[0].nodeValue).getElementsByTagName("Name")[0].childNodes[0].nodeValue;
function entityfromid(id) {
$($(xmlDoc)[0].getElementsByTagName("Entities")[0].childNodes).each(function (index, value) {
if(value.getElementsByTagName('Id')[0].childNodes[0].nodeValue == id) {
return value;
}
});
}