1377349460.298

Xpath query in this situation - grouping values?

If I have this XML:

<Events>
    <Properties>
      <Property Descriptor="100">1377349460.298</Property>
      <Property Descriptor="101">1</Property>
      <Property Descriptor="24000">C1234Test1</Property>
    </Properties>
    <Properties>
      <Property Descriptor="100">1377349462.298</Property>
      <Property Descriptor="101">1</Property>
      <Property Descriptor="24000">C4321Test2</Property>
    </Properties>
    <Properties>
      <Property Descriptor="100">1377349462.300</Property>
      <Property Descriptor="101">1</Property>
      <Property Descriptor="24000">C1234Test1</Property>
    </Properties>
</Events>

How can I choose only Descriptor="100"for the FIRST occurrence of each Descriptor="24000", given only the first 5 characters of this property? For example, choosing only 1377349460.298 [for C1234] and 1377349462.298 [for C4321]?

Xpath 2.0

I don’t know how to try it ...

Thanks in advance!

+3
source share
1 answer

Find all the matching identifiers, then for each of them find the first result.

for $id in distinct-values(//Property[@Descriptor=24000]/substring(., 1, 4))
return
  //Properties[Property[@Descriptor=24000 and starts-with(., $id)]][1]
      /Property[@Descriptor=100]
+2
source

All Articles