title: Get value of child from the value of another child with the same parent in XML using PHP
body: <p>I have the following XML document:</p>
  
  <pre><code>&lt;response&gt;
      &lt;message&gt;
          &lt;badgeid&gt;13&lt;/badgeid&gt;
          &lt;level&gt;4672&lt;/level&gt;
          &lt;completion_time&gt;1518626787&lt;/completion_time&gt;
          &lt;xp&gt;4922&lt;/xp&gt;
          &lt;scarcity&gt;9717&lt;/scarcity&gt;
      &lt;/message&gt;
      &lt;message&gt;
          &lt;badgeid&gt;25&lt;/badgeid&gt;
          &lt;level&gt;1&lt;/level&gt;
          &lt;completion_time&gt;1480166791&lt;/completion_time&gt;
          &lt;xp&gt;25&lt;/xp&gt;
          &lt;scarcity&gt;3761041&lt;/scarcity&gt;
      &lt;/message&gt;
      &lt;message&gt;
          &lt;badgeid&gt;21&lt;/badgeid&gt;
          &lt;level&gt;1&lt;/level&gt;
          &lt;completion_time&gt;1467581153&lt;/completion_time&gt;
          &lt;xp&gt;100&lt;/xp&gt;
          &lt;scarcity&gt;16650345&lt;/scarcity&gt;
      &lt;/message&gt;
  &lt;/response&gt;
  </code></pre>
  
  <p>I am trying to create a program using PHP that returns the "scarcity" of a certain "badgeid" (that is always unique).</p>
  
  <p>So my question is: How do I get the value of <code>&lt;scarcity&gt;&lt;/scarcity&gt;</code> when the only input I receive from the user is a unique <code>badgeid</code>? In general words: How do I get the value of a child from the value of another child with the same parent?</p>