Abirami Rajendran
asked on
Linq query
I am trying to get elements from an XML that i created using XDocument.
XDocument books = new XDocument(
new XElement("Books",
new XElement("book",
new XElement("name", "Book 1"),
new XElement("author", "John Doe")),
new XElement("book",
new XElement("name", "Book 2"),
new XElement("author", "Jane Doe"))));
IEnumerable<XElement> elements = books.Element("books").Ele ments("boo k");
foreach (XElement element in elements)
MessageBox.Show(element.To String());
I get an error at the line IEnumerable<XElement> elements "Object reference not set to an instance of an object."
any help?
XDocument books = new XDocument(
new XElement("Books",
new XElement("book",
new XElement("name", "Book 1"),
new XElement("author", "John Doe")),
new XElement("book",
new XElement("name", "Book 2"),
new XElement("author", "Jane Doe"))));
IEnumerable<XElement> elements = books.Element("books").Ele
foreach (XElement element in elements)
MessageBox.Show(element.To
I get an error at the line IEnumerable<XElement> elements "Object reference not set to an instance of an object."
any help?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not a problem, glad I was able to help. ;=)
ASKER