我有以下嵌套循环
foreach (XmlNode nodeT in root.ChildNodes)
{
foreach (XmlNode nodeServicio in nodeT.ChildNodes)
{
nombreMayusculas = nodeServicio.Name.ToUpper();
if (nombreMayusculas.Contains("SERVICE"))
{
int a = 0;
int.TryParse(nombreMayusculas.Replace("SERVICE", ""), out a);
if (a.Equals(Type))
{
//some logic here to process only the matching Xmlnode
}
}
}
}
编辑 有没有办法只循环匹配两个条件的匹配 XmlNodes ?
我尝试使用Where
linq 方法,但不可用,我已经有了using System.Linq
这是XML
<Clients>
<AgoraCOR1 Type=\"SP\" Default=\"False\">
<Connectionstring>CONN_STRING</Connectionstring>
<Service002>SaveOperationNotification</Service002>
<Service106>SaveOrderNotification</Service106>
</AgoraCOR1>
<SerficorpOrdenes1 Type=\"SP\" Default=\"False\">
<Connectionstring>CONN_STRING</Connectionstring>
<Service106>SaveOrderNotification</Service106>
<Service017>SaveComplementationNotification</Service017>
</SerficorpOrdenes1>
<CorrevalCORInterno1 Type=\"SP\" Default=\"False\">
<Connectionstring>CONN_STRING</Connectionstring>
<Service002>SaveOperationNotification</Service002>
<Service074>SaveIndicatorNotification</Service074>
<Service106>SaveOrderNotification</Service106>
<Service017>SaveComplementationNotification</Service017>
<Service072>SalvarNotificacionPreciosDeMercado</Service072>
</CorrevalCORInterno1>
</Clients>