<?xml version="1.0" encoding="UTF-8"?> -<catalog> -<book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> <description> An in-depth look at creating applications with XML. </description> </book> -<book id="bk102"> <author>Ralls, Kim</author> <title>Midnight Rain</title> <genre>Fantasy</genre> <price>5.95</price> <publish_date>2000-12-16</publish_date> <description> A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world. </description> </book>
book id author title genre price publish_date description
XDocument doc = XDocument.Load("Book.xml"); if (doc != null) { foreach (var name in doc.Root.DescendantNodes().OfType().Select(x => x.Name).Distinct()) { ListBox1.Items.Add(name.ToString()); } }
var doc = new XDocument(); doc.Load(something); List<string> list=new List<string>(); foreach(var name in doc.Root.Element("catalog").DescendantNodes().OfType<XElement>() .Select(x => x.Name).Distinct()) { list.Add(name); } //Bind the list to Listbox
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)