|
-
Mar 7th, 2010, 07:46 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Get the Element with highest value
Linq2Xml:
[Edited]
I would like to get the count of elements where candidate has maximum/highest . I need some help.
Code:
<Pronvice_Data>
<Pronvice>PronviceA</Pronvice>
<Registered_Voters>115852</Registered_Voters>
<Sam_Kea>100</Sam_Kea>
<Jeje>500</Jeje>
<John_Doe>400</John_Doe>
</Pronvice_Data>
<Pronvice_Data>
<Pronvice>PronviceA</Pronvice>
<Registered_Voters>25852</Registered_Voters>
<Sam_Kea>200</Sam_Kea>
<Jeje>100</Jeje>
<John_Doe>300</John_Doe>
</Pronvice_Data>
<Pronvice_Data>
<Pronvice>PronviceC</Pronvice>
<Registered_Voters>317684</Registered_Voters>
<Sam_Kea>1000</Sam_Kea>
<Jeje>1200</Jeje>
<John_Doe>190</John_Doe>
</Pronvice_Data>
Expected Result:
Code:
Candidate | Won In
Jeje 2
John_Doe 1
Sam_Kea 0
Last edited by skea; Mar 7th, 2010 at 07:56 AM.
Reason: Edited
Using:VS 2008 Team System :: SQL Server 2005 Standard Edition.
----------------------------------------------------------------
-
Mar 7th, 2010, 11:35 AM
#2
Re: Get the Element with highest value
What language are you using to process the XML?
-
Mar 7th, 2010, 11:37 AM
#3
Addicted Member
Re: Get the Element with highest value
I can see from your tags that you have an XML file in place. Do you wish to extract the values with JavaScript and be able to tell which element has the highest value? Or do you wish to use another means to know which element has the highest value? I know it is possible to do this with JavaScript. But could you confirm this or be more specific please?
-
Mar 7th, 2010, 08:08 PM
#4
Thread Starter
Addicted Member
Re: Get the Element with highest value
Hi, i am using C# and here is how i load my XML
Code:
XDocument xmlVectors2 = XDocument.Load(@"C:\\Province_Data.xml");
var elemList= from elem in xmlVectors2.Descendants("Province_Data")
where elem.Elements().Count() > 1
select elem;
There is a standing solution here http://stackoverflow.com/questions/2...didate-has-won, but my problem is to get my structured XML in the foreach act as the source XDocument. Somehow, i cant get way to save it.
Last edited by skea; Mar 7th, 2010 at 08:15 PM.
Reason: edit
Using:VS 2008 Team System :: SQL Server 2005 Standard Edition.
----------------------------------------------------------------
-
Mar 8th, 2010, 04:45 PM
#5
Thread Starter
Addicted Member
Re: Get the Element with highest value
Using:VS 2008 Team System :: SQL Server 2005 Standard Edition.
----------------------------------------------------------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|