Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. XmlDocument errors = new XmlDocument();
  2. errors.Load("../../ErrorFile.xml");
  3. XmlElement root = errors.DocumentElement;
  4. XmlNode categoryNode = root.FirstChild;
  5. XmlNodeList nodes = categoryNode.ChildNodes;
  6. for (int i = 0; i < nodes.Count; i++)
  7. A.Items.Add(nodes[i].Name);
  8. string category = A.SelectedItem.ToString();
  9.  
  10. <root>
  11. <a name="1">
  12. <b>b1</b>
  13. <b>b2</b>
  14. <b>b3</b>
  15. </a>
  16. <a name="2">
  17. <b>c1</b>
  18. <b>c2</b>
  19. <b>c3</b>
  20. </a>
  21. </root>
  22.  
  23. XElement x;
  24.  
  25. public Form1()
  26. {
  27. InitializeComponent();
  28.  
  29. x = XElement.Load("In.xml");
  30. comboBox1.Items.AddRange(
  31. x.Elements("a")
  32. .Select(a => a.Attribute("name").Value)
  33. .ToArray());
  34. comboBox1.SelectedIndexChanged += new EventHandler((s, e) =>
  35. {
  36. comboBox2.Items.Clear();
  37. if (comboBox1.SelectedIndex > -1)
  38. {
  39. comboBox2.Items.AddRange(
  40. x.Elements("a")
  41. .First(a => a.Attribute("name")
  42. .Value
  43. .Equals(comboBox1.SelectedItem))
  44. .Elements()
  45. .Select(b => b.Value)
  46. .ToArray());
  47. }
  48. });
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement