473,508 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XPath help: Find element with most occurrences

STA
Hi.

Given this XML:
<itemdata>
<item>
<itemid>10</itemid>
<ctid>1</ctid>
</item>
<item>
<itemid>11</itemid>
<ctid>2</ctid>
</item>
<item>
<itemid>12</itemid>
<ctid>3</ctid>
</item>
<item>
<itemid>13</itemid>
<ctid>3</ctid>
</item>
<item>
<itemid>14</itemid>
<ctid>3</ctid>
</item>
<item>
<itemid>15</itemid>
<ctid>4</ctid>
</item>
<item>
<itemid>16</itemid>
<ctid>4</ctid>
</item>
</itemdata>

How can I find the ctid that occurs the most times? In this sample, I'm
looking for a result of "3", because there are 3 items where ctid=3,
and the next closest (4) only has 2 occurrences.

Thanks in advance for any help.
STA

Jun 26 '06 #1
1 1359
STA wrote:
How can I find the ctid that occurs the most times?


Just a SWAG, but: I'd suggest approaching this as a combination of a
grouping problem (find the items with the same ctid) and a sorting
problem (pick the longest group(s)).

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Jun 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6812
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
13
2487
by: tfsquare | last post by:
All, I am new to XSLT and having some problems understanding the syntax of XPath which selects nodes in the XML document. Consider this bit of XML, which contains three outer XML elements. ...
2
2688
by: Anna | last post by:
Hi all. I am using Jaxen to evaluate XPath expressions in Java. I encountered problems when comparing results returned by jaxen with results returned by other XPath implementation - I was using...
7
1796
by: steve bull | last post by:
I have the following code snippet to read the colorRange attributes for the colorRangeSwatch in the xml file listed below. string expr = "/swatches/colorRangeSwatch/colorRange";...
28
3253
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
5
2380
by: David Thielen | last post by:
Hi; I set up my xml as follows: XmlDocument xml = new XmlDocument(); xml.Load(File.Open("data.xml", FileMode.Open, FileAccess.Read)); XmlNamespaceManager context = new...
0
1128
by: KathyB | last post by:
Hi, sorry if this is the wrong group...but I don't see an xpath group and hoping someone here can help me. How do you assign variable to different elements within a single node set? I have a...
2
1290
by: Shen | last post by:
Hi, I have an array/arraylist of string items. What I want is to find out which item repeats itself most often. Any simple example for that? Thanks in advance. sean
0
7228
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7128
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7332
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5635
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
426
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.