Bonjour,

j'essaie de récupérer des infos dans un fichier xml.
Le fichier est composé de plusieurs blocs <Layer> structurés comme ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
<Layer queryable="1">
        <Name>PI_smf:Pluie_2m_fFm0_hr</Name>
        <Title>Pluie_2m_fFm0_hr</Title>
        <Abstract/>
        <KeywordList>
          <Keyword>WCS</Keyword>
          <Keyword>WorldImage</Keyword>
          <Keyword>Pluie_2m_fFm0_hr</Keyword>
        </KeywordList>
        <SRS>EPSG:900913</SRS>
        <!--WKT definition of this CRS:
PROJCS["WGS84 / Google Mercator", 
  GEOGCS["WGS 84", 
    DATUM["World Geodetic System 1984", 
      SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], 
      AUTHORITY["EPSG","6326"]], 
    PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], 
    UNIT["degree", 0.017453292519943295], 
    AXIS["Longitude", EAST], 
    AXIS["Latitude", NORTH], 
    AUTHORITY["EPSG","4326"]], 
  PROJECTION["Mercator_1SP"], 
  PARAMETER["semi_minor", 6378137.0], 
  PARAMETER["latitude_of_origin", 0.0], 
  PARAMETER["central_meridian", 0.0], 
  PARAMETER["scale_factor", 1.0], 
  PARAMETER["false_easting", 0.0], 
  PARAMETER["false_northing", 0.0], 
  UNIT["m", 1.0], 
  AXIS["x", EAST], 
  AXIS["y", NORTH], 
  AUTHORITY["EPSG","900913"]]-->
        <LatLonBoundingBox minx="55.45" miny="-20.892" maxx="55.544" maxy="-20.855"/>
        <BoundingBox SRS="EPSG:900913" minx="6172642.387" miny="-2379039.946" maxx="6183162.079" maxy="-2374655.632"/>
        <Style>
          <Name>raster</Name>
          <Title>Raster</Title>
          <Abstract>A sample style for rasters, good for displaying imagery</Abstract>
          <LegendURL width="20" height="20">
            <Format>image/png</Format>
            <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://observatoire-iuem.univ-brest.fr:8080/geoserver/wms?request=GetLegendGraphic&amp;format=image%2Fpng&amp;width=20&amp;height=20&amp;layer=Pluie_2m_fFm0_hr"/>
          </LegendURL>
        </Style>
      </Layer>

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
var i,j, n_layers, layers = docXML.getElementsByTagName("Layer");
					n_layers = layers.length;
					for (i = 0; i < n_layers; i++) {
						var layer = layers[i];
						if (layer.hasAttribute('queryable')) {							
							layerName = layer.getElementsByTagName("Name")[0].firstChild.nodeValue;
 
							if (layerName.substr(0,2)=="PI") {
								alert(layerName);
							}
						}
 
					}
ce morceau de code fonctionne.
Mais si je veux récupérer l'attribut minx de la balise BoundingBox, j'utilise ce code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
var i,j, n_layers, layers = docXML.getElementsByTagName("Layer");
					n_layers = layers.length;
					for (i = 0; i < n_layers; i++) {
						var layer = layers[i];
						if (layer.hasAttribute('queryable')) {							
							layerWest = layer.getElementsByTagName("BoundingBox")[0].firstChild.getAttribute("minx");
 
							if (layerName.substr(0,2)=="PI") {
								alert(layerWest);
							}
						}
 
					}
Dans la console d'erreur firefox, j'ai le message d'erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
layer.getElementsByTagName("BoundingBox")[0].firstChild is null
Est-ce que ça vient du mode de déclaration des balises ?
Name est déclaré sous la forme <Name></Name>
alors que BoundingBox est déclaré sous la forme <BoundingBox />

Ou est-ce que c'est tout autre chose ?
Comment faire ?

Merci,

Nico