Jesus Loves GRASS

Technical blog about GRASS/GIS,open source geoinformatics and MAPSERVER.

Friday, May 18, 2007

GML information in array form

The GML information is structured like this in the $key (dump programmin in the post below)

Keys array

Array
(
[SCHEMA] => Array
(
[0] => 0
[1] => 2
[2] => 4
[3] => 50
[4] => 51
)

[IMPORT] => Array
(
[0] => 1
)

[ELEMENT] => Array
(
[0] => 3
[1] => 9
[2] => 11
[3] => 13
[4] => 15
[5] => 17
[6] => 19
[7] => 21
[8] => 23
[9] => 25
[10] => 27
[11] => 29
[12] => 31
[13] => 33
[14] => 35
[15] => 37
[16] => 39
[17] => 41
)

[COMPLEXTYPE] => Array
........................ (more) .............

The number indicated by the key and the nested arrays is the location of of the specific tags inside the values array, for example the data from the first ELEMENT Tag will be in position 3 of the $Values array ([ELEMENT] => Array([0] => 3....)
Values array

Array
(
:
:
:
[3] => Array
(
[tag] => ELEMENT
[type] => complete
[level] => 2
[attributes] => Array
(
[NAME] => major_cities
[TYPE] => ms:major_citiesType
[SUBSTITUTIONGROUP] => gml:_Feature
)

)
:
:

An example to fetch the NAME data from the first ELEMENT would be:
$values[$keys["ELEMENT"][0]]["attributes"]["NAME"]

or using a more sofisticate approach with the point functions of PHP:
$values[reset($keys["ELEMENT"])]["attributes"]["NAME"]

This is not as sofisticates as the XML-DOM system but it works fine.

Labels: , ,

0 Comments:

Post a Comment

<< Home