Hi
I want to search for an element value in all the XML files(assume 200+) in a folder using C#.
My scenario is each file will contain multiple item tags.So i have to check all item tags for User Selected SearchValue. Eg: ABC123
Currently i am using foreach loop and it's taking longtime.
Could you please suggest me a better option to get result much faster
Following is my current code implementation.
string[] arrFiles = Directory.GetFiles(temFolder, "*.xml");
foreach (string file in arrFiles)
{
XmlDocument doc = new XmlDocument();
doc.Load(file);
XmlNodeList lstEquip = doc.SelectNodes("scene/PackedUnit/Items/ItemCode");
foreach (XmlNode xnEquip in lstEquip)
{
if (xnEquip.InnerText.ToUpper() == equipCode.ToUpper())
{
String[] strings = file.Split('\\');
string fileName = strings[strings.Count() - 1];
fileName = fileName.Replace(".xml", "");
lstSubContainers.Add(fileName);
break;
}
}
}
Thanks In Advance.