parse xml
-
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Xml; using System.IO; using System.Xml.Linq; namespace SearchApp { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public string _dir; public string _searchCriteria; /// <summary> /// validatate directory /// </summary> public string DirName { get { return _dir; } set { _dir = value; if (String.IsNullOrEmpty(value)) { throw new Exception("Directory is mandatory."); } } } /// <summary> /// validate search criteria /// </summary> public string SearchCriteria { get { return _searchCriteria; } set { _searchCriteria = value; if (String.IsNullOrEmpty(value)) { throw new Exception("Search Criteria is mandatory."); } } } private List<object> dataGridRows = new List<object>(); public MainWindow() { InitializeComponent(); DataContext = this; } private void Label_Loaded(object sender, RoutedEventArgs e) { } /// <summary> /// another way by which we can parse xml recursively /// </summary> /// <param name="element"></param> /// <param name="depth"></param> void ProcessXml(XElement element, int depth) { if (!element.HasElements) { } else { depth++; foreach (XElement child in element.Elements()) { ProcessXml(child, depth); } depth--; } } /// <summary>