I have an XML document (shown below), what I need to do is get a list of all the unique Type @ID values, regardless of where they are below SizeRanges
So for this document I need to get 10,8,6,5 into something I can use for-each upon.
Ultimately, I’m trying to show each SizeRange in a table beside each other, and get the same Types to line up on the same row. But the problem I am having is extracting a distinct list of Types I can loop on.
XML Document:
<SizeRanges>
<SizeRange ID="1" Name="8-18">
<Types>
<Type ID="10">
<Size Name="8" Quantity="1" />
<Size Name="10" Quantity="2" />
<Size Name="12" Quantity="2" />
<Size Name="14" Quantity="3" />
<Size Name="16" Quantity="1" />
<Size Name="18" Quantity="1" />
</Type>
<Type ID="8">
<Size Name="8" Quantity="1" />
<Size Name="10" Quantity="1" />
<Size Name="12" Quantity="2" />
<Size Name="14" Quantity="2" />
<Size Name="16" Quantity="1" />
<Size Name="18" Quantity="1" />
</Type>
<Type ID="6">
<Size Name="8" Quantity="1" />
<Size Name="10" Quantity="1" />
<Size Name="12" Quantity="1" />
<Size Name="14" Quantity="1" />
<Size Name="16" Quantity="1" />
<Size Name="18" Quantity="1" />
</Type>
<Type ID="5">
<Size Name="10" Quantity="1" />
<Size Name="12" Quantity="1" />
<Size Name="14" Quantity="1" />
<Size Name="16" Quantity="1" />
<Size Name="18" Quantity="1" />
</Type>
</Types>
</SizeRange>
<SizeRange ID="2" Name="S-XL">
<Types>
<Type ID="10">
<Size Name="S" Quantity="1" />
<Size Name="M" Quantity="3" />
<Size Name="L" Quantity="4" />
<Size Name="XL" Quantity="2" />
</Type>
<Type ID="8">
<Size Name="S" Quantity="1" />
<Size Name="M" Quantity="2" />
<Size Name="L" Quantity="3" />
<Size Name="XL" Quantity="2" />
</Type>
<Type ID="6">
<Size Name="S" Quantity="1" />
<Size Name="M" Quantity="2" />
<Size Name="L" Quantity="2" />
<Size Name="XL" Quantity="1" />
</Type>
<Type ID="5">
<Size Name="S" Quantity="1" />
<Size Name="M" Quantity="1" />
<Size Name="L" Quantity="2" />
<Size Name="XL" Quantity="1" />
</Type>
</Types>
</SizeRange>
</SizeRanges>
Give this a shot:
Here’s another way: