给定以下 XML(这是 Excel XML 数据表中的两行),我想查找所有Cost值并找到关联的AltID
...
<Row ss:AutoFitHeight="0">
<Cell ss:StyleID="s62"><Data ss:Type="String" AltID="1" ColumnHeader="AltName">Alternative 2</Data></Cell>
<Cell ss:StyleID="s62"><Data ss:Type="Number" ColumnHeader="Total">0.105468638</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="Number" ColumnHeader="Cost">123</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="Number" ColumnHeader="Risk">456</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell ss:StyleID="s62"><Data ss:Type="String" AltID="2" ColumnHeader="AltName">Alternative 3</Data></Cell>
<Cell ss:StyleID="s62"><Data ss:Type="Number" ColumnHeader="Total">1.7803949999999999</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="Number" ColumnHeader="Cost">123</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="Number" ColumnHeader="Risk">456</Data></Cell>
</Row>
...
我可以很容易地找到 Costs ,但我需要找到一种方法来说明,使用这个给定的成本,将“上升”一个级别到Row,然后找到 ColumnHeader 等于 AltName 的单元格,然后给我AltID属性。
Dim costs = From item In dg...<Table>...<Row>...<Cell>...<Data> Select item Where item.@ColumnHeader = "Cost"
For Each i In costs
dim CostValue as Integer = i.value
dim AltID as Integer = ...
Next