Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- XmlDocument errors = new XmlDocument();
- errors.Load("../../ErrorFile.xml");
- XmlElement root = errors.DocumentElement;
- XmlNode categoryNode = root.FirstChild;
- XmlNodeList nodes = categoryNode.ChildNodes;
- for (int i = 0; i < nodes.Count; i++)
- A.Items.Add(nodes[i].Name);
- string category = A.SelectedItem.ToString();
- <root>
- <a name="1">
- <b>b1</b>
- <b>b2</b>
- <b>b3</b>
- </a>
- <a name="2">
- <b>c1</b>
- <b>c2</b>
- <b>c3</b>
- </a>
- </root>
- XElement x;
- public Form1()
- {
- InitializeComponent();
- x = XElement.Load("In.xml");
- comboBox1.Items.AddRange(
- x.Elements("a")
- .Select(a => a.Attribute("name").Value)
- .ToArray());
- comboBox1.SelectedIndexChanged += new EventHandler((s, e) =>
- {
- comboBox2.Items.Clear();
- if (comboBox1.SelectedIndex > -1)
- {
- comboBox2.Items.AddRange(
- x.Elements("a")
- .First(a => a.Attribute("name")
- .Value
- .Equals(comboBox1.SelectedItem))
- .Elements()
- .Select(b => b.Value)
- .ToArray());
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement