[OpenLayers-Users] GML and GetFeatureInfo

mpriour mpriour at kestrelcomputer.com
Tue Nov 4 07:36:41 EST 2008


The status of my attempt at parsing a GML GetFeatureInfo response can be
found here:
http://trac.openlayers.org/ticket/1812

However, neither that nor the GML parser will help you extract attributes
from this GML response. They both expect an attribute name as a tagName of
an xml node and the attribute value as the inner text of that node.
For example:
<AttributeName1>attribute value 1</AttributeName1>
<AttributeName2>attribute value 2</AttributeName2>
etc....
However your attributes are formated as thus:

Spencer, Andrew wrote:
> 
>     <mxp:FeatureMembers>
>       <mxp:Feature>
>         <mxp:Val ref="Organisation">My Organisation</mxp:Val>
>         <mxp:Val ref="Name">My Area Name</mxp:Val>
>         <mxp:Val ref="Effective">My Date</mxp:Val>
>         <mxp:Val ref="Comments" />No Comments</mxp:Val>
>         <mxp:Val ref="ID">1000</mxp:Val>
>       </mxp:Feature>
>     </mxp:FeatureMembers>
> 
You would probably be best served using OpenLayers.Format.XML and doing
something like the following example:
var xmlParser = new OpenLayers.Format.XML();        
//get feature nodes
var featureNodes = xmlParser.getElementsByTagNameNS(GML Response String,                                                    
"http://www.mapinfo.com/mxp","Feature");
.......
//for each feature node, get attribute nodes
var attributeNodes = xmlParser.getElementsByTagNameNS(featureNode[i],                                                    
"http://www.mapinfo.com/mxp","Val");
.....
For each attribute node get the attribute from the 'ref' attribute and the
value from the innerText


Spencer, Andrew wrote:
> 
> Hi All,
> 
> I've seen this issue raised several times, the response has often not
> solved the issue as far as I can tell. I believe Matt Priour, one of the
> contributors here, was looking at a more elegant solution, but I don't
> know what the status of that is (Matt???). However, my issue is that we
> use MapInfo MapXtreme as our WMS server. GetFeatureInfo requests are
> returned as XML/GML, but I'm not able to parse it into a formatted
> response. Using code from the sample project, attribute info is
> displayed in one long string, so I'd like to get in there and apply
> headings and line breaks etc. The xml parsing example can be made to
> pull out gml:name and gml:metaDataProperty, but I can't get to anything
> else. The XML looks a bit like this:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <FeatureCollectionList xmlns:gml="http://www.opengis.net/gml"
> xmlns:xlink="http://www.w3.org/1999/xlink"
> xmlns="http://www.mapinfo.com/mxp">
>   <FeatureCollection xmlns:mxp="http://www.mapinfo.com/mxp"
>   xmlns:gml="http://www.opengis.net/gml"
>   xmlns:xlink="http://www.w3.org/1999/xlink">
>     <gml:metaDataProperty>
>       <mxp:FeatureCollectionMetaData>
>         <mxp:AttributeDefinitionSet>
>           <mxp:ValueAttributeDefinition id="Organisation"
>           name="Organisation" type="mapinfo:type string 100" />
>           <mxp:ValueAttributeDefinition id="Name" name="Name"
>           type="mapinfo:type string 40" />
>           <mxp:ValueAttributeDefinition id="Gazetted"
>           name="Gazetted" type="mapinfo:type date" />
>           <mxp:ValueAttributeDefinition id="Effective"
>           name="Effective" type="mapinfo:type date" />
>           <mxp:ValueAttributeDefinition id="Comments"
>           name="Comments" type="mapinfo:type string 120" />
>           <mxp:ValueAttributeDefinition id="ID" name="ID"
>           type="mapinfo:type short" />
>         </mxp:AttributeDefinitionSet>
>         <mxp:KeyDefinition refs="Organisation Comments" />
>       </mxp:FeatureCollectionMetaData>
>     </gml:metaDataProperty>
>     <gml:name>My Feature Type Name</gml:name>
>     <gml:boundedBy>
>       <gml:Null>missing</gml:Null>
>     </gml:boundedBy>
>     <mxp:FeatureMembers>
>       <mxp:Feature>
>         <mxp:Val ref="Organisation">My Organisation</mxp:Val>
>         <mxp:Val ref="Name">My Area Name</mxp:Val>
>         <mxp:Val ref="Effective">My Date</mxp:Val>
>         <mxp:Val ref="Comments" />No Comments</mxp:Val>
>         <mxp:Val ref="ID">1000</mxp:Val>
>       </mxp:Feature>
>     </mxp:FeatureMembers>
>   </FeatureCollection>
> </FeatureCollectionList>
> 
> If anyone has any ideas I'd be eternally grateful!
> 
> Cheers
> Andrew
> If this email has been received in error, please delete all copies
> and inform the National Native Title Tribunal by return email or
> telephone 1800 640 501. 
> The Tribunal does not warrant that its email is virus free.
> All emails sent to the Tribunal are filtered for viruses and
> inappropriate content. Thus your email may not reach the person to
> whom it is addressed. Seek confirmation of receipt of your email if you
> consider the email important.
>  
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

-- 
View this message in context: http://www.nabble.com/GML-and-GetFeatureInfo-tp20315696p20321433.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list