Last post Dec 15, 2015 09:02 AM by Nan Yu
Member
77 Points
74 Posts
Dec 15, 2015 08:40 AM|Melody_xxxx|LINK
i have a xml,I want to get the max value from attribute of a node
All-Star
18815 Points
3831 Posts
Dec 15, 2015 09:02 AM|Nan Yu|LINK
Hi Melody ,
Melody_xxxx i have a xml,I want to get the max value from attribute of a node
You could use Linq to Xml to achieve that . For example , if xml like:
<?xml version="1.0" encoding="utf-8"?> <FeeGroups> <FeeGroup value="1"> <FeegId>100</FeegId> <Fgname>sss</Fgname> <FgDetail>dgdgdgdg</FgDetail> /> </FeeGroup> <FeeGroup value="2"> <FeegId>101</FeegId> <Fgname>sss1</Fgname> <FgDetail>rtrtrt</FgDetail> </FeeGroup> <FeeGroup value="4"> <FeegId>102</FeegId> <Fgname>sss2</Fgname> <FgDetail>klklkl</FgDetail> </FeeGroup> <FeeGroup value="1"> <FeegId>103</FeegId> <Fgname>sss3</Fgname> <FgDetail>mnmnmn</FgDetail> </FeeGroup> </FeeGroups>
If I want to get the max value of FeeGroup , code below is for your reference :
int maxValue = XDocument.Load(@"D:\TEST.xml").Descendants("FeeGroup") .Max(x => (int)x.Attribute("value"));
Best Regards,
Nan Yu
Member
77 Points
74 Posts
xml help
Dec 15, 2015 08:40 AM|Melody_xxxx|LINK
i have a xml,I want to get the max value from attribute of a node
All-Star
18815 Points
3831 Posts
Re: xml help
Dec 15, 2015 09:02 AM|Nan Yu|LINK
Hi Melody ,
You could use Linq to Xml to achieve that . For example , if xml like:
If I want to get the max value of FeeGroup , code below is for your reference :
Best Regards,
Nan Yu