Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 13th, 2013  |  syntax: None  |  size: 0.95 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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));