导航xml节点以在数据网格中显示的问题

时间:2012-12-13 12:32:00

标签: wpf xml xaml wpfdatagrid

我正在使用WPF和一个稍微不寻常的xml文件,我试图用它来填充数据网格。在根节点和重复的顺序节点之间,有四个节点是根的子节点,并且仅出现在顶部,我似乎无法导航到达订单节点。如果我删除前四个节点,它会按预期填充。

这是不起作用的xml:

<evec_api method="quicklook" version="2.0">
<quicklook>
<item>40</item>
<itemname>Megacyte</itemname>
<regions/><hours>360</hours>
<minqty>10001</minqty>
<sell_orders>
<order id="2686762970">
<region>10000002</region>
<station>60003760</station>
<station_name>Jita IV - Moon 4 - Caldari Navy Assembly Plant</station_name>
<security>0.9</security>
<range>32767</range>
<price>2534.98</price>
<vol_remain>750000</vol_remain>
<min_volume>1</min_volume>
<expires>2013-03-13</expires>
<reported_time>12-13 10:54:11</reported_time>
</order>
<order id="2686763351">
<region>10000002</region>
<station>60003760</station>
<station_name>Jita IV - Moon 4 - Caldari Navy Assembly Plant</station_name>
<security>0.9</security>
<range>32767</range>
<price>2545.99</price>
<vol_remain>709273</vol_remain>
<min_volume>1</min_volume>
<expires>2013-03-13</expires>
<reported_time>12-13 10:54:11</reported_time>
</order>
</sell_orders>
</quicklook>
</evec_api>

XAML(不适用于上述内容):

<DataGrid x:Name="grid" ItemsSource="{Binding Path=Element
Element[item].Element[itemname].Element[regions].Element[minqty]
.Element[sell_orders].Elements[order]}">

这是xml减去前四个有效的节点:

<evec_api method="quicklook" version="2.0">
<quicklook>
<sell_orders>
<order id="2686762970">
<region>10000002</region>
<station>60003760</station>
<station_name>Jita IV - Moon 4 - Caldari Navy Assembly Plant</station_name>
<security>0.9</security>
<range>32767</range>
<price>2534.98</price>
<vol_remain>750000</vol_remain>
<min_volume>1</min_volume>
<expires>2013-03-13</expires>
<reported_time>12-13 10:54:11</reported_time>
</order>
<order id="2686763351">
<region>10000002</region>
<station>60003760</station>
<station_name>Jita IV - Moon 4 - Caldari Navy Assembly Plant</station_name>
<security>0.9</security>
<range>32767</range>
<price>2545.99</price>
<vol_remain>709273</vol_remain>
<min_volume>1</min_volume>
<expires>2013-03-13</expires>
<reported_time>12-13 10:54:11</reported_time>
</order>
</sell_orders>
</quicklook>
</evec_api>

XAML(适用于上面的xml):

<DataGrid x:Name="grid" ItemsSource="{Binding Path=Element
[quicklook].Element[sell_orders].Elements[order]}">

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

你不必浏览那些不需要的标签,所以你的最后一个绑定应该适用于两个xmls

祝你好运