XML Document Structure -
xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Type TypeName="Functions">
<Details FunctionName="InActiveUsers_Mail" ClientList="Etihad,Malasia" />
<Details FunctionName="UnAssignedUsers_Mail" ClientList="Etihad,Virgin" />
</Type>
<Type TypeName="Mails">
<Details FunctionName="InActiveUsers_Mail" ClientList="Etihad,Malasia" />
<Details FunctionName="UnAssignedUsers_Mail" ClientList="Malasia,Virgin" />
</Type>
</Root>
Load XML Document in DataTable -
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Environment.CurrentDirectory + "\\ClientWiseFunctionality.xml");
XmlNodeList elemList =
xmlDoc.GetElementsByTagName("Type");
oXmlDataTable.Columns.AddRange(new DataColumn[2] {new DataColumn("FunctionName", typeof(string)),new DataColumn("ClientList",typeof(string)) });
foreach (XmlNode node in elemList)
{
if (node.Attributes["TypeName"].Value == "Functions")
{
foreach (XmlNode childnode in node)
{
oXmlDataTable.Rows.Add(childnode.Attributes["FunctionName"].Value,
childnode.Attributes["ClientList"].Value);
}
}
}
Load XML data in DataTable and use LINQ on
it
var dttt = (from n in oXmlDataTable.AsEnumerable()
where n.Field<string>("FunctionName") == "UnAssignedUasdsers_Mail"
&& n.Field<string>("ClientList").Split(',').Any(i => i.Equals("Malasia"))
select n).ToList();
Comments
Post a Comment