[OpenLayers-Users] Extract/read attributes from GML

Christopher Schmidt crschmidt at metacarta.com
Wed Nov 14 11:00:02 EST 2007


On Wed, Nov 14, 2007 at 07:17:08AM -0800, springrider wrote:
> 
> Good morning
> 
> I would be interested to extract/read text within some tags
> (wfs:FeatureCollection\gml:boundedBy\gml:Box\gml:coordinates) from my GML. I
> am now struggling trying to write the correct syntax. I tried something like
> that:
>  var myGml= new
> OpenLayers.Layer.GML("myGML","http://193.43.36.238:8282/geoserver/wfs?request=GetFeature&typename=fifao:Fao_areas&cql_filter=F_AREA=27");
> var myExtent=
> myGml.read("wfs:FeatureCollection\gml:boundedBy\gml:Box\gml:coordinates")
> 
> But it is not correct.Could you please help me? I would then use this text
> to define the extent of my map.

This isn't going to do what you want it to do.

1. None of the OpenLayers libraries include support for xpath like
navigation of XML documents.
2. The GML parser returns features; additional metadata from the
document is ignored.
3. The Layer is just about displaying data; you're more likely to want
to use the Format (but it still won't do what you want.)

You'll probably want to use the Format.XML class to load the data, and
use standard DOM methods to manipulate the loaded XML, or the Format.XML
specific getElementsByTagNameNS and the like. 

OpenLayers is a map library, rather than a geodata management framework,
so it doesn't provide the tools to do what you want easily, as far as
I'm aware.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list