Count number of elements with a given attribute
Posted: Fri Feb 15, 2008 7:19 pm
In my xml file, I have several elements of the form (with contents omitted):
<Msg Id="100" Direction="Send"/>
<Msg Id="200" Direction="Send"/>
<Msg Id="300" Direction="Receive"/>
<Msg Id="400" Direction="Receive"/>
I'd like to count the number of nodes with Direction="Send", and count the number of nodes with Direction="Receive".
I can count the number of nodes, but I'd like to count based on the attribute Direction.
More specifically, I'd like to detect the break in the direction sequence, and do something special when direction changes from Send to Receive (just once, not at each Receive node).
Thanks for suggestions.
-- Mike
<Msg Id="100" Direction="Send"/>
<Msg Id="200" Direction="Send"/>
<Msg Id="300" Direction="Receive"/>
<Msg Id="400" Direction="Receive"/>
I'd like to count the number of nodes with Direction="Send", and count the number of nodes with Direction="Receive".
I can count the number of nodes, but I'd like to count based on the attribute Direction.
More specifically, I'd like to detect the break in the direction sequence, and do something special when direction changes from Send to Receive (just once, not at each Receive node).
Thanks for suggestions.
-- Mike