Advertisement
Guest User

Untitled

a guest
Jun 13th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. XmlNodeList elemList = xmlDoc.GetElementsByTagName("company");
  2. foreach (XmlNode node in elemList)
  3. {
  4. if (node.Attributes[0].Value == company)
  5. {
  6. foreach (XmlNode child in node.ChildNodes)
  7. {
  8. foreach (XmlNode detail in child.ChildNodes)
  9. {
  10. ddlCodes.Items.Add(detail.Value.ToString());
  11. }
  12. }
  13. }
  14. }
  15.  
  16. <companies>
  17. <company id="company1">
  18. <code>12</code>
  19. <detail>detail of 12 code</detail>
  20. </company>
  21. <company id="company2">
  22. <code>15</code>
  23. <detail>detail of 15 code</detail>
  24. </company>
  25. </companies>
  26.  
  27. [XmlRoot("companies")]
  28. public class Root
  29. {
  30. [XmlElement("company")]
  31. public company[] companies;
  32. }
  33.  
  34. public class company
  35. {
  36. [XmlAttribute("id")]
  37. public string id;
  38. public string code;
  39. public string detail;
  40. }
  41.  
  42.  
  43. XmlSerializer xml = new XmlSerializer(typeof(Root));
  44. Root r = (Root)xml.Deserialize(new StringReader(xmlstr));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement