Dim Xdoc as Xelement = Xelement.Load( "C:\text.xml")
今天要把 裡面的資料 依 RcpNO 排序
XDoc = New XElement(<RecipeList><%= From rcp In XDoc.Elements("Recipe") _
Select rcp _
Order By CInt(rcp.Elements("RcpNo").Value) %>
</RecipeList>)
可用 Order by 的方式 ,來排序資料
===================================================
test.xml 內的資料
<?xml version="1.0" encoding="utf-8"?>
<RecipeList>
<Recipe>
<RcpNo>1001</RcpNo>
<RcpName>SEtest2</RcpName>
<Recipe>
<RcpNo>1011</RcpNo>
<RcpName>123</RcpName>
</Recipe>
<Recipe>
<RcpNo>1005</RcpNo>
<RcpName>RStest1</RcpName>
</Recipe>
</Recipe>
<Recipe>
<RcpNo>1002</RcpNo>
<RcpName>ABCD</RcpName>
</Recipe>
</RecipeList>
- 1月 14 週六 201220:38
XML 與 Linq (四) 資料排序
文章標籤
全站熱搜
