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-
<?xml version="1.0" encoding="UTF-8"?><wfs:FeatureCollection xmlns="http://www.opengis.net/wfs" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:spoin="http://jabber.int/spoin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jabber.int/spoin http://192.168.10.233:8080/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=spoin%3Apoints http://www.opengis.net/wfs http://192.168.10.233:8080/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd"><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=" ">-1,-1 0,0</gml:coordinates></gml:Box></gml:boundedBy></wfs:FeatureCollection>
<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection xmlns="http://www.opengis.net/wfs"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:gml="http://www.opengis.net/gml"
xmlns:spoin="http://jabber.int/spoin"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jabber.int/spoin
http://192.168.10.233:8080/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=spoin%3Apoints
http://www.opengis.net/wfs http://192.168.10.233:8080/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd">
<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>
<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>
</wfs:FeatureCollection>
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users