count occurences

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi
I hav the following xml structure..

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Blue; ?>
<span style="color:Blue; <<span style="color:#A31515; products<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; product <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; serial<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 11<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Name<span style="color:Blue; >12000572<span style="color:Blue; </<span style="color:#A31515; Name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; artnr<span style="color:Blue; >1111<span style="color:Blue; </<span style="color:#A31515; artnr<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; artnr<span style="color:Blue; >2222<span style="color:Blue; </<span style="color:#A31515; artnr<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; product<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; product <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 22<span style="color:Black; " <span style="color:Red; serial<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 333<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Name<span style="color:Blue; >12000572<span style="color:Blue; </<span style="color:#A31515; Name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; artnr<span style="color:Blue; >1111<span style="color:Blue; </<span style="color:#A31515; artnr<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; artnr<span style="color:Blue; >444<span style="color:Blue; </<span style="color:#A31515; artnr<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; product<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; products<span style="color:Blue; >
[/code]

How can I count the number of occurences of a specific artnr element where I first need to filter out based on product id and serial attribute. For example, Lets say that I need to check if there are any artnr that is called "1111" where the product
id=22 and product serial=333. This should result in one occurence in the above xml file.

Can someone please show how this can be done?



View the full article
 
Back
Top