Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- XmlNodeList elemList = xmlDoc.GetElementsByTagName("company");
- foreach (XmlNode node in elemList)
- {
- if (node.Attributes[0].Value == company)
- {
- foreach (XmlNode child in node.ChildNodes)
- {
- foreach (XmlNode detail in child.ChildNodes)
- {
- ddlCodes.Items.Add(detail.Value.ToString());
- }
- }
- }
- }
- <companies>
- <company id="company1">
- <code>12</code>
- <detail>detail of 12 code</detail>
- </company>
- <company id="company2">
- <code>15</code>
- <detail>detail of 15 code</detail>
- </company>
- </companies>
- [XmlRoot("companies")]
- public class Root
- {
- [XmlElement("company")]
- public company[] companies;
- }
- public class company
- {
- [XmlAttribute("id")]
- public string id;
- public string code;
- public string detail;
- }
- XmlSerializer xml = new XmlSerializer(typeof(Root));
- Root r = (Root)xml.Deserialize(new StringReader(xmlstr));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement