I am trying to get all the elements of a "video" and their attributes from an XML file that looks like this:
<?xml version="1.0" encoding="utf-8" ?> <videos> <video title="video1" path="videos\video1.wma"/> <video title="video2" path="videos\video2.wma"/> <video title="video3" path="videos\video3.wma"/> </videos>
Below, we select only the root of the node and all the children. I would like to get all the elements of the video in IEnumerable. Can someone tell me what I'm doing wrong?
IEnumerable<XElement> elements = from xml in _xdoc.Descendants("videos") select xml;
The above returns a collection with length == 1. It contains the root element and all child elements.
source share