我的任务是在listBox1中选择项目时,弄清楚如何使用关联的<S>
元素值填充第二个listBox。 listBox1中的项是相关(通过属性值)<V>
元素的连接值。
我有以下XML:
<ServiceHistoryArray>
<RecordID>XD116067*401529</RecordID>
<SWR>
<V Idx="1">7932</V><V Idx="2">7932</V><V Idx="3">7932</V><V Idx="4">7932</V>
</SWR>
<Comments/>
<Mileage>6</Mileage>
<Operation>
<V Idx="1">Z7000*WPDIP****PRE-DELIVERY INSPECTION - BASE TIME</V><V Idx="2">Z911*INC****ETCH WINDOWS</V><V Idx="3">B0048*WPBS4****FASCIA, FRONT BUMPER - REPLACE ONE PIECE</V><V Idx="4">9997*WPBS4****</V>
</Operation>
<CloseDate>1998-12-30</CloseDate>
<OpenDate>1998-10-16</OpenDate>
<PartsAmount>
<V Idx="1">0.00</V><V Idx="2">0.00</V><V Idx="3">166.32</V><V Idx="4">0.00</V>
</PartsAmount>
<LaborAmount>
<V Idx="1">64.80</V><V Idx="2">3.60</V><V Idx="3">140.40</V>
</LaborAmount>
<Warranty>
<S Idx="1">ü96ü0ýý10232632ü4Hü1</S><S Idx="2">ü96ü0ýý10232632ü4Hü1</S><S Idx="3">ü96ü0ýý10232632ü4Hü1</S>
</Warranty>
</ServiceHistoryArray>
我有以下c#代码:
// Linq query to find all service history line items
var queryDetail = from v in xdoc.Descendants("V")
group v by (int)v.Attribute("Idx") into g
select String.Join(" ", g.Select(x => (string)x));
// Iterates through the linq query and populates listBox1 with the servcie history details
foreach (string serviceInfo in queryDetail)
{
listBox1.Items.Add(serviceInfo);
}
澄清:
LINQ查询采用所有相关的(按属性值)<V>
元素,将它们连接成一行,并将它们添加到listBox1。
当listBox1中选中相关(按属性值)项时,我需要让listBox2显示相应的<S>
元素。
如果需要进一步澄清或提供信息,请告知。
2013年7月29日:尚未命中。在我的问题中是否有一些我需要帮助的东西?