title: Selecting XmlNode's Child Nodes based on Tag
body: <p>I'm trying to parse this XML Document:</p>
  
  <pre><code>&lt;MPD&gt;
    &lt;Period duration="PT0H3M1.63S" start="PT0S"&gt;
      &lt;AdaptationSet&gt;
        &lt;ContentComponent contentType="video" id="1" /&gt;
        &lt;Representation bandwidth="4190760" codecs="avc1.640028" height="1080" id="1" mimeType="video/mp4" width="1920"&gt;
          &lt;BaseURL&gt;car-20120827-89.mp4&lt;/BaseURL&gt;
        &lt;/Representation&gt;
        &lt;Representation bandwidth="2073921" codecs="avc1.4d401f" height="720" id="2" mimeType="video/mp4" width="1280"&gt;
          &lt;BaseURL&gt;car-20120827-88.mp4&lt;/BaseURL&gt;
        &lt;/Representation&gt;
      &lt;/AdaptationSet&gt;
      &lt;AdaptationSet&gt;
        &lt;ContentComponent contentType="audio" id="2" /&gt;
        &lt;Representation bandwidth="127236" codecs="mp4a.40.2" id="6" mimeType="audio/mp4" numChannels="2" sampleRate="44100"&gt;
          &lt;BaseURL&gt;car-20120827-8c.mp4&lt;/BaseURL&gt;
        &lt;/Representation&gt;
        &lt;Representation bandwidth="255236" codecs="mp4a.40.2" id="7" mimeType="audio/mp4" numChannels="2" sampleRate="44100"&gt;
          &lt;BaseURL&gt;car-20120827-8d.mp4&lt;/BaseURL&gt;
        &lt;/Representation&gt;
      &lt;/AdaptationSet&gt;
    &lt;/Period&gt;
  &lt;/MPD&gt;
  </code></pre>
  
  <p>using this C# code:</p>
  
  <pre><code>var rootDoc = new XmlDocument();
  rootDoc.LoadXml(xmlString); // the one from above
  
  var adaptationSets = rootDoc.GetElementsByTagName("AdaptationSet");
  
  if (adaptationSets.Count &gt; 0)
      foreach (XmlNode adaptionSet in adaptationSets) // Loop through AdaptionSets
      {
          // Get the one Node in this AdaptionSet with the ContentComponent-Tag
          var contentComponent = adaptionSet.SelectSingleNode("ContentComponent");
  
          if (contentComponent != null)
          {
              // parse attributes
          }
  
          // Get All Nodes in this AdaptionSet with the Representation-Tag
          var representations = adaptionSet.SelectNodes("Representation");
  
          if(representations?.Count &gt; 0)
              foreach (XmlNode representation in representations)
              {
                  // parse attributes of XmlNode
              }
      }
  </code></pre>
  
  <p>It all works except for the XPath queries. I tried a lot of variations with leading "/", "//", "./" and without any leading characters, but it just won't work. What am I doing wrong? I'm not using XPath on a regular basis and I couldn't find anything more than the leading characters I mentioned. Because I've seen it on a lot of other answers on this website I feel like I should mention that I'm explicitly looking for the XPath that will help me solve this, not some Linq variation or an entirely different approach.</p>
  
  <p>Any help is greatly appreciated. Thanks in advance!</p>