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>
- Jan 14 Sat 2012 20:38
XML 與 Linq (四) 資料排序
全站熱搜
留言列表
發表留言