Bino, If you access to the feature, for example features[i], you can get the fid by features[i].fid. If you require further information (attributes) there is an array containing that info features[i].attributes.
Un saludo, ·················································································· David Alda Fernández de Lezea Lurralde eta Biodibertsitate Saila / Dpto. de Territorio y Biodiversidad IKT Granja Modelo s/n · 01192 · Arkaute (Araba) ·················································································· Tlfnos.: 945-00-32-95 Fax: 945-00.32.90 ·················································································· email: [email protected] web: www.ikt.es ·················································································· -----Mensaje original----- De: [email protected] [mailto:[email protected]] En nombre de Bino Oetomo Enviado el: jueves, 07 de octubre de 2010 11:40 Para: [email protected] Asunto: [OpenLayers-Users] How to extract "fid" from GML Hi David Alda Fernandez de Lezea wrote: > Hi, > > I'm using geoserver in back-end, and the problem was that when I made the > getfeaureinfo request the returned response contained the '1' character > (maybe is the number of matched results) so when I was parsing the gml I got > no features and no errors. When I realized what the problema was, I could > make it work with the following code: > > data = data.substring(0,data.length-1); > > var theParser = new OpenLayers.Format.GML(); > theParser.internalProjection = null; theParser.externalProjection = > null; > theParser.extractStyles = false; > theParser.extractAttributes = true; > var features = theParser.read(data); > > //Iterate through features > ... > Yup, just before I read your post ... I solved my problem to. Attached is 2 xml file 1. gml21.xml : This is the original saved from GetFeatureInfo call 2. gml21a.xml : Same as above but manualy rearranged just for human readability factor Curently my parsing fungtion is : //------START Function function setHTML(req) { g = new OpenLayers.Format.GML(); html = "" features = g.read(req.responseText); for(var feat in features) { html += "Feature: Geometry: "+ features[feat].geometry+","; html += "<ul>"; for (var j in features[feat].attributes) { html += "<li>"+j+":"+features[feat].attributes[j]+"</li>"; } html += "</ul>" } document.getElementById('nodeList').innerHTML = html; }; //------STOP Function The current result is : //----START result Feature: Geometry: POINT(110.36599 -7.80068), * label:NGUPASAN * type:0xd00 * level:1 //----STOP result Part of the GML says : //--START GML <gml:featureMember> <spoin:points fid="points.205508"> <gml:boundedBy> <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> <gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">110.36599,-7.80068 110.36599,-7.80068</gml:coordinates> </gml:Box> </gml:boundedBy> <spoin:label>NGUPASAN</spoin:label> <spoin:type>0xd00</spoin:type> <spoin:level>1</spoin:level> <spoin:the_geom> <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> <gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">110.36599,-7.80068</gml:coordinates> </gml:Point> </spoin:the_geom> </spoin:points> </gml:featureMember> //--START GML My Question is : How to extract "FID" from the GML (inside <spoin:points fid="points.205508">) ? Specialy that "205508" number. Sincerely -bino- _______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
