I have document:
<build>
<name>TestName</name>
<contours>
<contour>
<entity_spatial>
<spatials_elements>
<spatial_element>
<ordinates>
<ordinate>
<x>578943.62</x>
<y>1403153.28</y>
</ordinate>
<ordinate>
<x>578943.19</x>
<y>1403159.55</y>
</ordinate>
<ordinate>
<x>578935.03</x>
<y>1403159.09</y>
</ordinate>
</ordinates>
</spatial_element>
</spatials_elements>
</entity_spatial>
</contour>
<contour>
<entity_spatial>
<spatials_elements>
<spatial_element>
<ordinates>
<ordinate>
<x>578935.46</x>
<y>1403152.82</y>
</ordinate>
<ordinate>
<x>578943.62</x>
<y>1403153.28</y>
</ordinate>
</ordinates>
</spatial_element>
</spatials_elements>
</entity_spatial>
</contour>
</contours>
</build>
So there i want to get list of x and y
. But i want to enumerate countour blocks. I mean:
contour x y
1 578943.62 1403153.28
1 578943.19 1403159.55
1 578935.03 1403159.09
1 578943.62 1403153.28
2 578935.46 1403152.82
2 578943.62 1403153.28
Now i can get list of x and y
:
declare @xml xml
set @xml = '
<build>
<name>TestName</name>
<contours>
<contour>
<entity_spatial>
<spatials_elements>
<spatial_element>
<ordinates>
<ordinate>
<x>578943.62</x>
<y>1403153.28</y>
</ordinate>
<ordinate>
<x>578943.19</x>
<y>1403159.55</y>
</ordinate>
<ordinate>
<x>578935.03</x>
<y>1403159.09</y>
</ordinate>
</ordinates>
</spatial_element>
</spatials_elements>
</entity_spatial>
</contour>
<contour>
<entity_spatial>
<spatials_elements>
<spatial_element>
<ordinates>
<ordinate>
<x>578935.46</x>
<y>1403152.82</y>
</ordinate>
<ordinate>
<x>578943.62</x>
<y>1403153.28</y>
</ordinate>
</ordinates>
</spatial_element>
</spatials_elements>
</entity_spatial>
</contour>
</contours>
</build>
'
select
xml_ordinates.ordinate.value('(./x)[1]','decimal(20,2)') AS X
,xml_ordinates.ordinate.value('(./y)[1]','decimal(20,2)') AS Y
from @xml.nodes('/build') land (land)
CROSS APPLY land.land.nodes('./contours/contour/entity_spatial/spatials_elements/spatial_element/ordinates/ordinate') xml_ordinates(ordinate)
But how can i enumerate contours
blocks?