次のネストされたループがあります
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>