title: PHP read xml and show particular value
body: <p>I want to have a PHP script that reads a .xml file and shows a certain value for something. So for example I want to find out what the "name" value is for classname "Jack-User2". and I want it to show "Jack". Or if I want to show the last name for classname of "John-User1" it would show "Henry".</p>
  
  <p>I've tried to search this up already, and have had not much luck with finding something that I need. I've found ones which you sent the number of order. But I want to be able to set a particular value and for it to find. </p>
  
  <p>So roughly what I want is something like this:</p>
  
  <pre><code>&lt;?php
  $classname = "John-User1";
  $xml = simplexml_load_file('myfile.xml');
  
  echo $name; //I want the name that is for John-User1 to appear here
  echo $lastname; //I want the last name here.
  ?&gt;
  </code></pre>
  
  <p>My XML file:</p>
  
  <pre><code>&lt;customerdata&gt;
      &lt;infotype&gt;
          &lt;usertype id="1" classname="John-User1"&gt;
              &lt;revision_id&gt;1223&lt;/revision_id&gt;
              &lt;firstname&gt;John&lt;/name&gt;
              &lt;lastname&gt;Henry&lt;/lastname&gt;
          &lt;/usertype&gt;
          &lt;usertype id="2" classname="Jack-User2"&gt;
              &lt;revision_id&gt;1223&lt;/revision_id&gt;
              &lt;name&gt;Jack&lt;/name&gt;
              &lt;lastname&gt;Thompson&lt;/lastname&gt;
          &lt;/usertype&gt;
          &lt;usertype id="3" classname="Brad-User3"&gt;
              &lt;revision_id&gt;1223&lt;/revision_id&gt;
              &lt;name&gt;Brad&lt;/name&gt;
              &lt;lastname&gt;Henry&lt;/lastname&gt;
          &lt;/usertype&gt;
          &lt;usertype id="4" classname="Jane-User4"&gt;
              &lt;revision_id&gt;1223&lt;/revision_id&gt;
              &lt;name&gt;Jane&lt;/name&gt;
              &lt;lastname&gt;Harrison&lt;/lastname&gt;
          &lt;/usertype&gt;
      &lt;/infotype&gt;
  &lt;/customdata&gt;
  </code></pre>
  
  <p>I'd really appreciate it if someone could help with this small project. Thanks</p>