.Net3.5 及以上版本中 XML 子节点的复杂排序

发布于 2024-08-30 17:47:05 字数 3515 浏览 4 评论 0原文

的 Xpath 类型表示

Records/Record/Actions/Action/ActionDate

XML 结构以同一级别的其他节点

Records/Record/Actions/Action/CTCDate

是否有简单或不简单的方法可以按“按 ActionDate,CTCDate 排序”(以 SQL 表示法)对其进行排序,但每个选定记录的操作(而不是每个 XML 文件) )当我们以某种方式迭代并生成排序的 XML 时。文件约50M

输入

  <Record>
    <Name>Zywocinski, Cynthia A.</Name>
    <Classification>Individual</Classification>
    <CTType>Reciprocal</CTType>
    <Addresses>
      <Address>
        <City>Lancaster</City>
        <ZIP>01523</ZIP>
        <Province/>
        <State>MA</State>
        <DUNS/>
      </Address>
    </Addresses>
    <References>
      <Reference>Zywocinski-White, Cynthia</Reference>
    </References>
    <Actions>
     <Action>
       <ActionDate>13-Oct-1999</ActionDate>
       <TermDate>Indef.</TermDate>
       <CTCode>Z1</CTCode>
       <AgencyComponent>HHS</AgencyComponent>
       <EPLSCreateDate>29-Jul-1999</EPLSCreateDate>
     </Action>
     <Action>
       <ActionDate>13-Oct-1999</ActionDate>
       <TermDate>Indef.</TermDate>
       <CTCode>A1</CTCode>
       <AgencyComponent>HHS</AgencyComponent>
       <EPLSCreateDate>29-Jul-1999</EPLSCreateDate>
     </Action>
     <Action>
       <ActionDate>20-Jul-1999</ActionDate>
       <TermDate>Indef.</TermDate>
       <CTCode>R</CTCode>
       <AgencyComponent>OPM</AgencyComponent>
       <EPLSCreateDate>29-Oct-1999</EPLSCreateDate>
     </Action>
    </Actions>
    <Description/>
    <AgencyIdentifiers/>
  </Record>

输出

  <Record>
    <Name>Zywocinski, Cynthia A.</Name>
    <Classification>Individual</Classification>
    <CTType>Reciprocal</CTType>
    <Addresses>
      <Address>
        <City>Lancaster</City>
        <ZIP>01523</ZIP>
        <Province/>
        <State>MA</State>
        <DUNS/>
      </Address>
    </Addresses>
    <References>
      <Reference>Zywocinski-White, Cynthia</Reference>
    </References>
    <Actions>
     <Action>
       <ActionDate>20-Jul-1999</ActionDate>
       <TermDate>Indef.</TermDate>
       <CTCode>R</CTCode>
       <AgencyComponent>OPM</AgencyComponent>
       <EPLSCreateDate>29-Oct-1999</EPLSCreateDate>
     </Action>
     <Action>
       <ActionDate>13-Oct-1999</ActionDate>
       <TermDate>Indef.</TermDate>
       <CTCode>A1</CTCode>
       <AgencyComponent>HHS</AgencyComponent>
       <EPLSCreateDate>29-Jul-1999</EPLSCreateDate>
     </Action>
     <Action>
       <ActionDate>13-Oct-1999</ActionDate>
       <TermDate>Indef.</TermDate>
       <CTCode>Z1</CTCode>
       <AgencyComponent>HHS</AgencyComponent>
       <EPLSCreateDate>29-Jul-1999</EPLSCreateDate>
     </Action>
    </Actions>
    <Description/>
    <AgencyIdentifiers/>
  </Record>

XML structure expressed in Xpath kind of

Records/Record/Actions/Action/ActionDate

the other node on the same level

Records/Record/Actions/Action/CTCDate

Is there easy or not easy way to sort it on "order by ActionDate,CTCDate" ( in SQL notation ), but per Actions for each selected Record ( not per XML file ) when we iterate somehow and generate sorted XML. File around 50M

Input

  <Record>
    <Name>Zywocinski, Cynthia A.</Name>
    <Classification>Individual</Classification>
    <CTType>Reciprocal</CTType>
    <Addresses>
      <Address>
        <City>Lancaster</City>
        <ZIP>01523</ZIP>
        <Province/>
        <State>MA</State>
        <DUNS/>
      </Address>
    </Addresses>
    <References>
      <Reference>Zywocinski-White, Cynthia</Reference>
    </References>
    <Actions>
     <Action>
       <ActionDate>13-Oct-1999</ActionDate>
       <TermDate>Indef.</TermDate>
       <CTCode>Z1</CTCode>
       <AgencyComponent>HHS</AgencyComponent>
       <EPLSCreateDate>29-Jul-1999</EPLSCreateDate>
     </Action>
     <Action>
       <ActionDate>13-Oct-1999</ActionDate>
       <TermDate>Indef.</TermDate>
       <CTCode>A1</CTCode>
       <AgencyComponent>HHS</AgencyComponent>
       <EPLSCreateDate>29-Jul-1999</EPLSCreateDate>
     </Action>
     <Action>
       <ActionDate>20-Jul-1999</ActionDate>
       <TermDate>Indef.</TermDate>
       <CTCode>R</CTCode>
       <AgencyComponent>OPM</AgencyComponent>
       <EPLSCreateDate>29-Oct-1999</EPLSCreateDate>
     </Action>
    </Actions>
    <Description/>
    <AgencyIdentifiers/>
  </Record>

Output

  <Record>
    <Name>Zywocinski, Cynthia A.</Name>
    <Classification>Individual</Classification>
    <CTType>Reciprocal</CTType>
    <Addresses>
      <Address>
        <City>Lancaster</City>
        <ZIP>01523</ZIP>
        <Province/>
        <State>MA</State>
        <DUNS/>
      </Address>
    </Addresses>
    <References>
      <Reference>Zywocinski-White, Cynthia</Reference>
    </References>
    <Actions>
     <Action>
       <ActionDate>20-Jul-1999</ActionDate>
       <TermDate>Indef.</TermDate>
       <CTCode>R</CTCode>
       <AgencyComponent>OPM</AgencyComponent>
       <EPLSCreateDate>29-Oct-1999</EPLSCreateDate>
     </Action>
     <Action>
       <ActionDate>13-Oct-1999</ActionDate>
       <TermDate>Indef.</TermDate>
       <CTCode>A1</CTCode>
       <AgencyComponent>HHS</AgencyComponent>
       <EPLSCreateDate>29-Jul-1999</EPLSCreateDate>
     </Action>
     <Action>
       <ActionDate>13-Oct-1999</ActionDate>
       <TermDate>Indef.</TermDate>
       <CTCode>Z1</CTCode>
       <AgencyComponent>HHS</AgencyComponent>
       <EPLSCreateDate>29-Jul-1999</EPLSCreateDate>
     </Action>
    </Actions>
    <Description/>
    <AgencyIdentifiers/>
  </Record>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文