請幫我將這個多級xml讀取到RadGrid中。 1)我計劃不要爲此使用Aspx 2)名爲Item的節點最終會根據應用程序需求進行更改。所以,我不想通過將XMLNode限制我的XPath來類似「//產品/項目」如何讀取vb.net中的多級xml,綁定到radgrid
<Products>
<Product ProductID="1">
<Item ItemID="1">
<ProductNo>1234</ProductNo>
<Description>
<ManufacDate>20100526T12:00:01.012</ManufacDate>
<ManufacID>72</ManufacID>
</Description>
</Item>
<Item ItemID="2">
<ProductNo>1235</ProductNo>
<Description>
<ManufacDate>20100527T12:00:01.012</ManufacDate>
<ManufacID>72</ManufacID>
</Description>
</Item>
<Item ItemID="3">
<ProductNo>1236</ProductNo>
<Description>
<ManufacDate>20100528T12:00:01.012</ManufacDate>
<ManufacID>66</ManufacID>
</Description>
</Item>
</Product></Products>
我讀從代碼隱藏這個XML和迭代在網格中顯示。請在下面找到我的代碼段:
Dim root as new xmldocument()
' After loading the above xml into root
Dim ndl As XmlNodeList = root.SelectNodes("//Products")
For Each chNode As XmlNode In ndl
Dim chObjNode As XmlNodeList = root.SelectNodes("descendant::node()[ancestor::Product[@ProductID=""1""]]")
For Each XNode As XmlNode In chObjNode
ds.ReadXml(New XmlNodeReader(XNode))
Next
Next
radgrid1.datasource = ds
radgrid1.databind()
考慮到this參考。 如果您可以幫助我更正或提供此問題的解決方案而無需轉換爲XSL,那就太好了。我需要Columns:ItemID,ProductNo,用ManufacDate和ManufacID縮進描述。我不知道如何讓這個顯示。
感謝