【问题标题】:What xpath can I use to map multiple records in reverse order (starting with the last record and ending with the first)?我可以使用什么 xpath 以相反的顺序映射多条记录(从最后一条记录开始并以第一条记录结束)?
【发布时间】:2013-12-11 23:53:10
【问题描述】:

我目前正在使用:loadTable:Import[@source='People']/rep/employment_history/employment

我使用的语言允许我获取 XML 中的所有记录并按从头到尾的顺序映射它们。是否有其他语言可以让我从最后一条记录开始映射到第一条记录结束?

这个xpath需要应用于数百人,所以记录的数量并不总是3,但我总是需要它们以它们出现的相反顺序。

以下 XML:

-<Import firmCrd="0" date="6/17/2013" source="People">
  -<rep xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     -<employment_history>-<employment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><employment_id>51379</employment_id><rep_id>14718</rep_id><emp_seq>1</emp_seq><employer_name>Fake Name</employer_name><biz_type/><employee_title>OTHER - HOME PARTY CONSULTANT INDEP. C</employee_title><street1/><street2/><city>SAN DIEGO</city><state>CA</state><zip/><country/><start_date>1988-01-01T00:00:00</start_date><end_date>1989-09-01T00:00:00</end_date><inv_related>0</inv_related><crd_seq_num>1</crd_seq_num></employment>
   -<employment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><employment_id>51380</employment_id><rep_id>14718</rep_id><emp_seq>2</emp_seq><employer_name>UNEMPLOYED</employer_name><biz_type/><employee_title>OTHER</employee_title><street1/><street2/><city>WILMINGTON</city><state>MT</state><zip/><country/><start_date>1988-01-01T00:00:00</start_date><end_date>1989-09-01T00:00:00</end_date><inv_related>0</inv_related><crd_seq_num>3</crd_seq_num></employment>
   -<employment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><employment_id>51381</employment_id><rep_id>14718</rep_id><emp_seq>3</emp_seq><employer_name>PIZZA HUT</employer_name><biz_type/><employee_title>OTHER - WAITRESS</employee_title><street1/><street2/><city>ALBANY</city><state>NY</state><zip/><country/><start_date>1989-09-01T00:00:00</start_date><end_date>1992-08-01T00:00:00</end_date><inv_related>0</inv_related><crd_seq_num>4</crd_seq_num></employment></employment_history>

【问题讨论】:

    标签: xml xpath


    【解决方案1】:

    XPath 没有排序或排序功能,因为您需要 XQuery 或 XSLT。

    【讨论】:

      猜你喜欢
      • 2017-05-08
      • 2020-07-07
      • 2019-12-28
      • 1970-01-01
      • 2017-02-24
      • 1970-01-01
      • 1970-01-01
      • 2015-08-21
      • 1970-01-01
      相关资源
      最近更新 更多