<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Yes. Thanks for the answer. This is an extract of the code.</span></div><div><br><span></span></div><div style="font-style: italic;"><span>puntigml = new OpenLayers.Layer.GML("Specimens", "/gis/GeoLayer.gml",{projection: new OpenLayers.Projection("EPSG:4326")});</span></div><div style="font-style: italic;"><span>map.addLayer(puntigml);</span><span><br></span></div><div style="font-style: italic;"><span>select_feature_control =new OpenLayers.Control.SelectFeature(<br> puntigml,<br> {<br>
multiple: false,<br> toggle: true,<br> multipleKey: 'shiftKey',<br> toggleKey: 'ctrlKey',<br> box: true
<br> }<br> );<br> <br>map.addControl(select_feature_control);</span></div><div style="font-style: italic;"><br><span></span></div><div style="font-style: italic;"><span>function selezione_elemento(event) {<br> //info record<br> var
tipo=event.feature.attributes.type; </span><span>// comment#1</span><br><span> var collect=event.feature.attributes.place.name; //comment#2<br> var famiglia=event.feature.attributes.family;<br> var specie=event.feature.attributes.species;<br> document.getElementById('tipo').innerHTML=tipo;<br> document.getElementById('collection').innerHTML=collect;<br></span></div><div style="font-style: italic;"><span>}</span></div><div style="font-style: italic;"><span>puntigml.events.register('featureselected', this, selezione_elemento);</span></div><div><br><span></span></div><div><span>This is an example of my gml file</span></div><div><br><span></span></div><div style="font-style:
italic;"><span><gml:featureMember></span></div><div style="font-style: italic;"><span><gml:Specimens></span></div><div style="font-style: italic;"><span><type>herbaria</type> // comment#1<br></span></div><div style="font-style: italic;"><span><species>Quercus cerris L.</species></span></div><div style="font-style: italic;"><span><place></span></div><div style="font-style: italic;"><span class="tab"> </span><span><name>Valle di Copogna-Monte Lago</name> //comment #2<br></span></div><div style="font-style: italic;"><span class="tab"> </span><span><town>Serravalle di Chienti</town></span></div><div style="font-style: italic;"><span class="tab"> </span><span><province>Macerata</province></span></div><div style="font-style: italic;"><span class="tab">
</span><span><region>Marche</region></span></div><div style="font-style: italic;"><span class="tab"> </span><span><country>Italia</country></span></div><div style="font-style: italic;"><span></place></span></div><div style="font-style: italic;"><span><ogr:geometryProperty></span></div><div style="font-style: italic;"><span><gml:Polygon srsName="EPSG:4326"></span></div><div style="font-style: italic;"><span><gml:outerBoundaryIs></span></div><div style="font-style: italic;"><span><gml:LinearRing></span></div><div style="font-style: italic;"><span><gml:coordinates>12.916666749999999,43.100000000000001 13,43.100000000000001 13,43.149999999999999 12.916666749999999,43.149999999999999 12.916666749999999,43.100000000000001</gml:coordinates></gml:LinearRing></span></div><div style="font-style: italic;"><span></gml:outerBoundaryIs></span></div><div style="font-style:
italic;"><span></gml:Polygon></span></div><div style="font-style: italic;"><span></ogr:geometryProperty></span></div><div style="font-style: italic;"><span></gml:Specimens></span></div><div style="font-style: italic;"><span></gml:featureMember></span></div><div><br><span></span></div><div><span>When I try to access to a first order node like <type> or <species> the selection function works (look comment #1) but when I try to access to a subtag doesn't extract any information and the firebug result is <br></span></div><div><span><span style="font-style: italic;">event.feature.place is undefined - var collect=event.feature.place.name;</span><br></span></div><div><br></div><div>Thanks again,</div><div><br></div><div><br></div><div>Francesco<br></div><div><br></div> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif;
font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1"> <b><span style="font-weight:bold;">Da:</span></b> Pierre Stévens <pieside@gmx.com><br> <b><span style="font-weight: bold;">A:</span></b> Francesco Geri <francescogeri@yahoo.it> <br> <b><span style="font-weight: bold;">Inviato:</span></b> Lunedì 16 Aprile 2012 16:12<br> <b><span style="font-weight: bold;">Oggetto:</span></b> Re: [OpenLayers-Users] gml and attributes<br> </font> </div> <br>Hello,<br><br>"event.feature.field1.field2" is normally the right way to access to <br>attribute "field2".<br><br>1. Check if "field2" is correctly written.<br>2. It can be other thing<br><br>Can you give us the real lines (not with <field1><field2>...</field1>)? <br>It can help more.<br><br><br>Le lun 16 avr 2012 15:51:32 CEST, Francesco Geri a écrit :<br>> Hello,<br>> I have some problems whie I try to access to the attributes of gml<br>> file
stored in subtag. Normally when I use the<br>> event.feature.attributes.field1 I can extract the attributes stored in<br>> the node "field1". But when I have a situation like this<br>><br>> <field1><br>> <field2><br>> information<br>> </field2><br>> </field1><br>><br>> How I can access to the field2 node? I try with<br>> event.feature.field1.field2 but I obtain an undefined value.<br>><br>> thanks to all,<br>><br>><br>> Francesco<br>><br>><br>> _______________________________________________<br>> Users mailing list<br>> <a ymailto="mailto:Users@lists.osgeo.org" href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>> <a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br><br><br><br><br> </div> </div> </div></body></html>