xml - XPath count adjacent nodes with similar attribute value -


i wonder if help. have xml, like:

  <foo>     <bar id="1">       <chu id="1" val="2" />       <chu id="2" val="2" />       <chu id="3" val="3" />       <chu id="4" val="3" />       <chu id="5" val="3" />       <chu id="6" val="4" />       <chu id="7" val="3" />       <chu id="8" val="3" />       <chu id="9" val="3" />     </bar>     <bar id="2">       <chu id="1" val="2" />       <chu id="2" val="2" />       <chu id="3" val="3" />       <chu id="4" val="3" />       <chu id="5" val="3" />       <chu id="6" val="3" />       <chu id="7" val="5" />       <chu id="8" val="2" />       <chu id="9" val="3" />     </bar>   </foo> 

my requirement quite complex, want find "bar" node longest 'streak' (must adjacent) of similar "chu" elements have value 3. i'd know length of streak.

so, in example xml node returned "bar" id=2 , count of streak 4 ("chu" id 3 thru 6).

i.e. i'm not counting number of "chu"s val=3, has 'streak' of adjacent elements.

it's hurting head, ideas appreciated.

thanks,

simon


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -