diff --git a/lib/OpenLayers/Format/WMSGetFeatureInfo.js b/lib/OpenLayers/Format/WMSGetFeatureInfo.js index 00521aa295..2362b1524c 100644 --- a/lib/OpenLayers/Format/WMSGetFeatureInfo.js +++ b/lib/OpenLayers/Format/WMSGetFeatureInfo.js @@ -177,27 +177,27 @@ OpenLayers.Format.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Format.XML, { if (node && node.hasChildNodes()) { children = node.childNodes; n = children.length; - child = children[0]; - while (child && child.nodeType != 1) { - child = child.nextSibling; - } - tagName = (child ? child.nodeName : ''); - if (tagName.length > 0 && tagName.indexOf(criteria) > -1) { - for (var i = 0; i < n; i++) { - child = children[i]; - if (child.nodeType == 1) { - nodes.push(child); + + for(var k=0; k 0 && tagName.indexOf(criteria) > -1) { + nodes.push(child); + } else { + matchNodes = this.getSiblingNodesByTagCriteria( + child, criteria); + + if(matchNodes.length > 0){ + (nodes.length == 0) ? + nodes = matchNodes : nodes.push(matchNodes); } } } - else { - for (var i = 0; i < n; i++) { - matchNodes = this.getSiblingNodesByTagCriteria( - children[i], criteria); - (nodes.length == 0) ? - nodes = matchNodes : nodes.push(matchNodes); - } - } + } return nodes; },