xml - How to select unique nodes -


i found this page describing muenchian method, think i'm applying wrong.

consider return set of ages:

/doc/class/person/descriptive[(@name='age')]/value 

1..2..2..2..3..3..4..7

but nodeset 1 node each age.

1..2..3..4..7

each of these seem return of values, instead of unique values:

/doc/class/person/descriptive[(@name='age')][not(value=preceding-sibling::value)]/value /doc/class/person/descriptive[(@name='age')]/value[not(value=preceding-sibling::value)] 

what missing?

here's example:

<root>     <item type='test'>a</item>     <item type='test'>b</item>     <item type='test'>c</item>     <item type='test'>a</item>     <item type='other'>a</item>     <item type='test'>b</item>     <item type='other'>d</item>     <item type=''>a</item> </root> 

and xpath:

//preceding::item/preceding::item[not(.=preceding-sibling::item)]/text() 

results: b c d

edit: mousio commented doesn't capture last item in list if it's time appears. taking , fëanor's comment account, here's better solution:

/root/item[not(.=preceding-sibling::item)] 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -