public List <Films> Search(Films f, string path) { result.Clear(); Name = f.Name; Year = f.Year; Ganre = f.Ganre; RunningTime = f.RunningTime; Country = f.Country; Rate = f.Rate; Parsing(path); return(result); }
private static void Parsing(string path) { int f = 0; var xmlReader = new XmlTextReader(@path); while (xmlReader.Read()) { f = 0; if (xmlReader.HasAttributes) { Films res = new Films(); while (xmlReader.MoveToNextAttribute()) { if (xmlReader.Name == "Name") { if (Name != null && Name != xmlReader.Value) { f = 1; break; } res.Name = xmlReader.Value; } if (xmlReader.Name == "Year") { if (Year != null && Year != xmlReader.Value) { f = 1; break; } res.Year = xmlReader.Value; } if (xmlReader.Name == "Ganre") { if (Ganre != null && Ganre != xmlReader.Value) { f = 1; break; } res.Ganre = xmlReader.Value; } if (xmlReader.Name == "RunningTime") { if (RunningTime != null && RunningTime != xmlReader.Value) { f = 1; break; } res.RunningTime = xmlReader.Value; } if (xmlReader.Name == "Country") { if (Country != null && Country != xmlReader.Value) { f = 1; break; } res.Country = xmlReader.Value; } if (xmlReader.Name == "Rate") { if (Rate != null && Rate != xmlReader.Value) { f = 1; break; } res.Rate = xmlReader.Value; } } if (f == 0 && res.Name != null && res.Year != null && res.Ganre != null && res.RunningTime != null && res.Country != null && res.Rate != null) { result.Add(res); } } } }
private static void RecurseNodes(XmlNode node, int level) { Films res = new Films(); if (level == 1) { int f = 0; foreach (XmlAttribute attr in node.Attributes) { if (attr.Name == "Name") { if (Name != null && Name != attr.Value) { f = 1; break; } res.Name = attr.Value; } if (attr.Name == "Year") { if (Year != null && Year != attr.Value) { f = 1; break; } res.Year = attr.Value; } if (attr.Name == "Ganre") { if (Ganre != null && Ganre != attr.Value) { f = 1; break; } res.Ganre = attr.Value; } if (attr.Name == "RunningTime") { if (RunningTime != null && RunningTime != attr.Value) { f = 1; break; } res.RunningTime = attr.Value; } if (attr.Name == "Country") { if (Country != null && Country != attr.Value) { f = 1; break; } res.Country = attr.Value; } if (attr.Name == "Rate") { if (Rate != null && Rate != attr.Value) { f = 1; break; } res.Rate = attr.Value; } } if (f == 0) { result.Add(res); } } foreach (XmlNode n in node.ChildNodes) { RecurseNodes(n, level + 1); } }