如何从XML中获取值最高的ID?
我有一个带有几个如何从XML中获取值最高的ID?,xml,vb.net,Xml,Vb.net,我有一个带有几个InterimConditionEventID的简单xml。我想获得具有最高值的InterimConditionEvent ID 对于我的xml,我希望得到,因为它的值最高 如何在VB.Net中实现这一点 我的xml <Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCod
InterimConditionEvent
ID的简单xml。我想获得具有最高值的InterimConditionEvent ID
对于我的xml,我希望得到
,因为它的值最高
如何在VB.Net中实现这一点
我的xml
<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper">
<Case InternalID="1617095448" ID="12131576" xmlns:user="http://tylertechnologies.com">
<InterimConditionEvent ID="160850198">
<OrderDate>08/14/2015</OrderDate>
<ExpirationDate>08/14/2015</ExpirationDate>
<TimestampCreate>08/14/2015 11:01:57:700</TimestampCreate>
<TimestampChange>08/14/2015 11:21:51:623</TimestampChange>
<Deleted>true</Deleted>
<InterimCondition>
<ConditionType Word="DOMNC">Domestic No Contact</ConditionType>
<EffectiveDate>8/14/2015</EffectiveDate>
<EndDate>8/21/2015</EndDate>
</InterimCondition>
</InterimConditionEvent>
<InterimConditionEvent ID="160850209">
<OrderDate>08/14/2015</OrderDate>
<ExpirationDate>08/14/2015</ExpirationDate>
<TimestampCreate>08/14/2015 11:22:28:900</TimestampCreate>
<TimestampChange>08/14/2015 11:31:15:890</TimestampChange>
<Deleted>true</Deleted>
<InterimCondition>
<ConditionType Word="DOMNC">Domestic No Contact</ConditionType>
<EffectiveDate>8/14/2015</EffectiveDate>
<EndDate>8/14/2015</EndDate>
</InterimCondition>
</InterimConditionEvent>
</Case>
请尝试Linq到XML:
Dim xDoc As XElement = XElement.Load("file.xml")
Dim conditionEvents = xDoc.Element("Case").Elements("InterimConditionEvent")
Dim maxId As String = conditionEvents.Attributes("ID").Max(Function(attr) attr.Value)
Dim eventNode As XElement = (From elem In conditionEvents
Where elem.Attribute("ID").Value = maxId
Select elem).Single()
不确定,但可能此线程可以帮助您: