c# - Filter data from an XML document -



c# - Filter data from an XML document -

i have next xml file.

<jamstatus> <ipaddress value="10.210.104.32 " facid="2"> <type>letter</type> <jobid>1</jobid> <fi>50-30c-kmc-360a</fi> <timestampprinting>1309464601:144592</timestampprinting> </ipaddress> <ipaddress value="10.210.104.32 " facid="2"> <type>letter</type> <jobid>2</jobid> <fi>50-30c-kmc-360a</fi> <timestampprinting>1309465072:547772</timestampprinting> </ipaddress> <ipaddress value="10.210.104.32 " facid="2"> <type>letter</type> <jobid>2</jobid> <fi>50-30c-kmc-360a</fi> <timestampprinting>1309465072:547772</timestampprinting> </ipaddress> </jamstatus>

there may number of ipaddress elememt in document. jobid , timestamp can same perticular ipaddress. want count of ipaddress value, jobid , timestampprinting same. in case 2. best way information?

is there simple method without using linq?

thanks, syd

you can utilize xelement , linq:

var s = @" <jamstatus> <ipaddress value=""10.210.104.32 "" facid=""2""> <type>letter</type> <jobid>1</jobid> <fi>50-30c-kmc-360a</fi> <timestampprinting>1309464601:144592</timestampprinting> </ipaddress> <ipaddress value=""10.210.104.32 "" facid=""2""> <type>letter</type> <jobid>2</jobid> <fi>50-30c-kmc-360a</fi> <timestampprinting>1309465072:547772</timestampprinting> </ipaddress> <ipaddress value=""10.210.104.32 "" facid=""2""> <type>letter</type> <jobid>2</jobid> <fi>50-30c-kmc-360a</fi> <timestampprinting>1309465072:547772</timestampprinting> </ipaddress> </jamstatus>"; xelement xel = xelement.parse(s); console.writeline(xel.xpathselectelements("//ipaddress") .groupby(el => new tuple<string, string>(el.element((xname)"jobid").value, el.element((xname)"timestampprinting").value)) .max(g => g.count()) );

c# xml

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -