Actually I Want to get values from XML in C# in list. There are some specific conditions like. I need to show ruleid, dataprovider, in attribute I want to get name, in conditions in need to get value(20),operator(greaterthan or lessthan) of type="Healthy".
I have attached a image for the example XML.
I tried to parse the data in the following way :
public static void readXml()
{
XmlDocument xmldoc = new XmlDocument();
XmlNodeList xmlnode;
int i = 0;
List<Rule> listx = new List<Rule>();
FileStream fs = new FileStream("C://ConsoleApplication1//sample_manifest.xml", FileMode.Open, FileAccess.Read);
xmldoc.Load(fs);
xmlnode = xmldoc.GetElementsByTagName("attribute", "condition");
XmlNodeList list = xmldoc.SelectNodes(@"/psmsmanifiest/rules/rule/attributes");
foreach (XmlNode node in list)
{
foreach (XmlNode childNode in node.ChildNodes)
{
//string dataprovider = node["Dataprovider"].Attributes.Item(0);
var attribute = node["attribute"].InnerXml;
Console.WriteLine(attribute);
Console.ReadLine();
}
}
}