<div dir="ltr"><div><div>I'm trying to format the attributes of a WMS layer myself.<br></div>The WMS layer is made from a shapefile using Geoserver.<br></div>Using Google I found this piece of code:<br><br> var infoControl = new OpenLayers.Control.WMSGetFeatureInfo({<br>
url: serverLocation, <br> title: 'Get data',<br> queryVisible: true,<br> infoFormat: 'application/vnd.ogc.gml',<br> output: 'features',<br>
eventListeners: {<br> getfeatureinfo: function(event) {<br> console.log(event.features.length);<br> for (var i = 0; i < event.features.length; i++) {<br> var feature = event.features[i];<br>
var attributes = feature.attributes;<br> console.log(attributes);<br> document.getElementById('info').innerHTML = attributes[0]; <br> }<br>
}<br> }<br> });<br> map.addControl(infoControl);<br> infoControl.activate();<br><br clear="all"><div><div><div><div><div>This doesn't do anything because event.features.length is zero.<br>
</div><div>When I change the infoFormat to text and put event.text in my div I get the default formatted table.<br></div><div>So the response is correct. <br>When I use Firebug and look at the response of the GET that is send, I see my data in xml format.<br>
<br></div><div>So what am I missing that I cannot parse that xml into the event.features class.<br><br></div><div>Thanks,<br></div><div>
<br>
Paul</div>
</div></div></div></div></div>