ユーザーが提供するソート属性値と子値によってXMLELEMENTをソート
<root>
\t <SectionItem>
\t \t <Cell columnid="1" InSeconds="1496761802">06/06/2017 03:10:02 PM</Cell>
\t \t <Cell columnid="2"> Error</Cell>
\t \t <Cell columnid="3"> abc</Cell>
\t \t <Cell columnid="4"> None</Cell>
\t \t <Cell columnid="5"> 1 </Cell>
\t \t <Cell columnid="6"> N/A</Cell>
\t \t <Cell columnid="7"> efg</Cell>
\t </SectionItem>
\t <SectionItem>
\t \t <Cell columnid="1" InSeconds="1496743990">06/06/2017 10:13:10 AM</Cell>
\t \t <Cell columnid="2"> Error</Cell>3
\t \t <Cell columnid="3"> o</Cell>
\t \t <Cell columnid="4"> None</Cell>
\t \t <Cell columnid="5"> 1 </Cell>
\t \t <Cell columnid="6"> N/A </Cell>
\t \t <Cell columnid="7"> ice age</Cell>
\t </SectionItem>
\t <SectionItem>
\t \t <Cell columnid="1" InSeconds="1496227357">31/05/2017 10:42:37 AM</Cell>
\t \t <Cell columnid="2"> Error</Cell>
\t \t <Cell columnid="3"> Microsoft-Windows-CAPI2</Cell>
\t \t <Cell columnid="4"> N/A</Cell>
\t \t <Cell columnid="5"> 513</Cell>
\t \t <Cell columnid="6"> N/A</Cell>
\t \t <Cell columnid="7">Access is denied.. </Cell>
\t </SectionItem>
\t <SectionItem>
\t \t <Cell columnid="1" InSeconds="1495568786">23/05/2017 07:46:26 PM</Cell>
\t \t <Cell columnid="2"> Error</Cell>
\t \t <Cell columnid="3"> Microsoft-Windows-Immersive-Shell</Cell>
\t \t <Cell columnid="4"> N/A</Cell>
\t \t <Cell columnid="5">2484</Cell>
\t \t <Cell columnid="6">SR</Cell>
\t \t <Cell columnid="7">hello</Cell>
\t </SectionItem>
\t <SectionItem>
\t \t <Cell columnid="1" InSeconds="1495568789">23/05/2017 07:46:29 PM</Cell>
\t \t <Cell columnid="2">Error</Cell>
\t \t <Cell columnid="3"> Application Hang </Cell>
\t \t <Cell columnid="4"> N/A</Cell>
\t \t <Cell columnid="5">1002</Cell>
\t \t <Cell columnid="6"> N/A</Cell>
\t \t <Cell columnid="7"> here is a error</Cell>
\t </SectionItem>
\t <SectionItem>
\t \t <Cell columnid="1" InSeconds="1495568740">23/05/2017 07:45:40 PM</Cell>
\t \t <Cell columnid="2"> Error</Cell>
\t \t <Cell columnid="3"> Application Error</Cell>
\t \t <Cell columnid="4"> Application Crashing Events</Cell>
\t \t <Cell columnid="5">1000</Cell>
\t \t <Cell columnid="6"> N/A</Cell>
\t \t <Cell columnid="7"> error number 3</Cell>
\t </SectionItem>
</root>
私はセル属性のセルの要素の値にsectionItem要素ベースをソートしたい場合は、ユーザーがどのようにすることができます与えColumnIDの私はこれに近づく?前もって感謝します。
ユーザーがcolunidに "1"を指定した場合、columnid = "1"のcellの値でsectionItemの基底をソートする必要があります。 ユーザがcolunidに "3"を指定した場合、sectionidemのbaseをcolumnid = "3"のCellの値にソートする必要があります。
私は質問をまとめるのが難しいため、質問を理解しやすくしたいと考えています。
私は以下の出力を取得する必要カラムID = "3"
でソートしていた場合:あなたは本当にデータテーブルを持っているとmehtodのDataTableを使用する必要があります
<root>
\t <SectionItem>
\t \t <Cell columnid="1" InSeconds="1496761802">06/06/2017 03:10:02 PM</Cell>
\t \t <Cell columnid="2"> Error</Cell>
\t \t <Cell columnid="3"> abc</Cell>
\t \t <Cell columnid="4"> None</Cell>
\t \t <Cell columnid="5"> 1 </Cell>
\t \t <Cell columnid="6"> N/A</Cell>
\t \t <Cell columnid="7"> efg</Cell>
\t </SectionItem>
\t <SectionItem>
\t \t <Cell columnid="1" InSeconds="1495568740">23/05/2017 07:45:40 PM</Cell>
\t \t <Cell columnid="2"> Error</Cell>
\t \t <Cell columnid="3"> Application Error</Cell>
\t \t <Cell columnid="4"> Application Crashing Events</Cell>
\t \t <Cell columnid="5">1000</Cell>
\t \t <Cell columnid="6"> N/A</Cell>
\t \t <Cell columnid="7"> error number 3</Cell>
\t </SectionItem>
\t <SectionItem>
\t \t <Cell columnid="1" InSeconds="1495568789">23/05/2017 07:46:29 PM</Cell>
\t \t <Cell columnid="2">Error</Cell>
\t \t <Cell columnid="3"> Application Hang </Cell>
\t \t <Cell columnid="4"> N/A</Cell>
\t \t <Cell columnid="5">1002</Cell>
\t \t <Cell columnid="6"> N/A</Cell>
\t \t <Cell columnid="7"> here is a error</Cell>
\t </SectionItem>
\t <SectionItem>
\t \t <Cell columnid="1" InSeconds="1496227357">31/05/2017 10:42:37 AM</Cell>
\t \t <Cell columnid="2"> Error</Cell>
\t \t <Cell columnid="3"> Microsoft-Windows-CAPI2</Cell>
\t \t <Cell columnid="4"> N/A</Cell>
\t \t <Cell columnid="5"> 513</Cell>
\t \t <Cell columnid="6"> N/A</Cell>
\t \t <Cell columnid="7">Access is denied.. </Cell>
\t </SectionItem>
\t <SectionItem>
\t \t <Cell columnid="1" InSeconds="1495568786">23/05/2017 07:46:26 PM</Cell>
\t \t <Cell columnid="2"> Error</Cell>
\t \t <Cell columnid="3"> Microsoft-Windows-Immersive-Shell</Cell>
\t \t <Cell columnid="4"> N/A</Cell>
\t \t <Cell columnid="5">2484</Cell>
\t \t <Cell columnid="6">SR</Cell>
\t \t <Cell columnid="7">hello</Cell>
\t </SectionItem>
\t <SectionItem>
\t \t <Cell columnid="1" InSeconds="1496743990">06/06/2017 10:13:10 AM</Cell>
\t \t <Cell columnid="2"> Error</Cell>3
\t \t <Cell columnid="3"> o</Cell>
\t \t <Cell columnid="4"> None</Cell>
\t \t <Cell columnid="5"> 1 </Cell>
\t \t <Cell columnid="6"> N/A </Cell>
\t \t <Cell columnid="7"> ice age</Cell>
\t </SectionItem>
</root>
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/linq-to-xml-overviewにお読みください。 linqを使ってすべてのSectionItem要素を取得した後、columnid属性に基づいて(下位の)Cell要素の値を選択し、結果に対してSort()を呼び出すように思えます。あなたがこのようなことから期待していることは本当に明確ではありません。 SectionItem属性?、Cell値?とにかく、それはかなりまっすぐ前方linqクエリで行うことができる何かのように見えます。 – Dweeberly
混乱して申し訳ありません。 sectionItem要素をソート順に取得しようとしています。 – Terry