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>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Rh 的頭像
    Rh

    程式狂想曲

    Rh 發表在 痞客邦 留言(0) 人氣()