title: XPath to select the nodes that matches
body: <p>I have a XML that looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;RootName&gt;
    &lt;RandomNode v="someValue"/&gt;
    &lt;Series&gt;
      &lt;Idendity v="C16"/&gt;
      &lt;CodeOut v="C41073"/&gt;
      &lt;Period&gt;
        &lt;TimePeriod v="2013-07-18T22:00Z/2013-07-19T22:00Z"/&gt;
        &lt;Resolution v="PT60M"/&gt;
        &lt;Interval&gt;
          &lt;Pos v="1"/&gt;
          &lt;Qty v="14.1"/&gt;
        &lt;/Interval&gt;
        &lt;Interval&gt;
          &lt;Pos v="2"/&gt;
          &lt;Qty v="20.7"/&gt;
        &lt;/Interval&gt;
  </code></pre>
  
  <p>And I need a xPath that returns all the <code>Period</code> nodes which matches these conditions:</p>
  
  <ul>
  <li>The node <code>CodeOut</code>/<code>CodeIn</code> has the value of any of the values that I have in an array</li>
  <li>This node <code>CodeOut</code> can be named <code>CodeOut</code> or <code>CodeIn</code>, but only one of these</li>
  <li>The date on <code>TimePeriod</code> must match </li>
  </ul>
  
  <p>The only node that repeates over the xml is the <code>Series</code> node. In other words, there is only one <code>Period</code> per <code>Series</code>, but there is a lot of different <code>Series</code>.</p>
  
  <p>For example, get all <code>Period</code> nodes which have his <code>Codeout</code> or <code>CodeIn</code> value to being <code>C41073</code> or <code>B85028</code> and the date being <code>2013-07-18</code>.</p>
  
  <p>I tried, to match the multiple names, using something like:</p>
  
  <pre><code>//*[@v="C41073"] | //*[@v="B85028"] | ...
  </code></pre>
  
  <p>But I think it will be better if only matches the correct nodes, just in case some other node has the same value, isn't it?</p>
  
  <p>I was searching to use something like "contains", but it works in a different way. </p>
  
  <p>I'm using .Net, if that matters, and I'm going to use this xPath on the <code>.SelectNodes()</code> function.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Something strange is happening. Maybe the syntax is not correct. Look at this tests:</p>
  
  <p>This: <code>doc.SelectNodes("/*")(0).Name</code>    is returning <code>RootName</code><br>
  This: <code>doc.SelectNodes("/*/*").Count</code>    is returning <code>912</code><br>
  This: <code>doc.SelectNodes("/*/*")(11).Name</code> is returning <code>Series</code>  </p>
  
  <p>But this: <code>doc.SelectNodes("/RootName").Count</code>  is returning <code>0</code><br>
  This: <code>doc.SelectNodes("/*/Series").Count</code>      is returning <code>0</code><br>
  And this: <code>doc.SelectNodes("/*/RootName").Count</code> is returning <code>0</code></p>
  
  <p>Making all the other xPath sequences suggested in answers not working.</p>
  
  <p><em>EDIT:</em></p>
  
  <p>Ok, it was the namespace, I did this:</p>
  
  <pre><code>Dim xmlnsManager As Xml.XmlNamespaceManager = New System.Xml.XmlNamespaceManager(doc.NameTable)
  xmlnsManager.AddNamespace("ns", "http://example")
  </code></pre>
  
  <p>And adding <code>ns:</code> before every element node name in the xPath sequence. (See this for more information about it: <a href="https://stackoverflow.com/questions/7241931/is-it-possible-to-specify-the-namespace-prefix-just-once-in-a-xpath-expression">Is it possible to specify the namespace prefix just once in a xpath expression?</a>)</p>