I'm pretty new in XML and LINQ. I've a XLM file like this:
<?xml version="1.0" encoding="utf-8"?>
<Headers xmlns="http://tempuri.org/GridLayerSchema.xsd">
<Header>
<Name>Layer0</Name>
<Fields FieldID="FieldID0" FieldName="FieldNameAll" FieldPosition="0"FieldPositionStart="0" FieldLenght="254" FieldEnable="true" />
</Header>
<Header>
<Name>Layer1</Name>
<Fields FieldID="FieldID0" FieldName="JetPosition" FieldPosition="0" FieldPositionStart="0" FieldLenght="14" FieldEnable="true" />
<Fields FieldID="FieldID1" FieldName="Owner" FieldPosition="1" FieldPositionStart="14" FieldLenght="14" FieldEnable="true" />
<Fields FieldID="FieldID2" FieldName="Item" FieldPosition="2" FieldPositionStart="28" FieldLenght="3" FieldEnable="true" />
</Header>
</Headers>
I need to explore the file in two ways.
- First I need to carge a combobox itemsource property with the Header.name
- Second I need to make a Datagrid header with the fiels of the select layer.
I've made a linq query for take the Name property, but dosn't work.
Dim xdoc As XDocument = XDocument.Load(My.Application.Info.DirectoryPath & "\Layers\Layers.xml")
Dim query = From el In xdoc...<Headers>
Select New Header With {.Name = el.@Name}
For Each e In query
HeadersCollection.Add(e)
Next