title: C# XML XDocument
body: <p>I am coding a media player in C# so I saved playlists in an XML as below :</p>
  
  <p><a href="https://i.stack.imgur.com/LdSqj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LdSqj.png" alt="XML"></a></p>
  
  <p>So I want to get attributes of playlist "name" and attribute of media "path".</p>
  
  <p>I am able to get both using this code :</p>
  
  <pre><code>var xdoc = XDocument.Load(@"mypath");
  
  var names = from i in xdoc.Descendants("playlist")
              select new
              {
                  Path = (string)i.Attribute("name")
              };
  
  var paths = from i in xdoc.Descendants("media")
              select new
              {
                  Path = (string)i.Attribute("path")
              };
  
  foreach (var name in names)
  {
      System.Diagnostics.Debug.WriteLine(name.Path);
      foreach (var path in paths)
          System.Diagnostics.Debug.WriteLine(path.Path);
  }
  </code></pre>
  
  <p>So I get this :</p>
  
  <p>Films</p>
  
  <pre><code>E:\Projets\CS - MyWindowsMediaPlayer\Example Medias\Music1.mp3
  E:\Projets\CS - MyWindowsMediaPlayer\Example Medias\MusicInfos1.mp3
  E:\Projets\CS - MyWindowsMediaPlayer\Example Medias\Video2.mp4
  E:\Projets\CS - MyWindowsMediaPlayer\Example Medias\Video1.mp4
  E:\Projets\CS - MyWindowsMediaPlayer\Example Medias\Video3.mp4
  </code></pre>
  
  <p>But I want to sort by categories, for example getting only links that corresponds with films.</p>