title: php parse xml get element same attribute value
body: <p>I am new in php.</p>
  
  <p>So, i want to parse xml from url like :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;all_emp&gt;
  &lt;emp_detail&gt;
      &lt;emp emp_name="john"&gt;&lt;img&gt;john_1.jpg&lt;/img&gt;&lt;/emp&gt;
      &lt;emp emp_name="john"&gt;&lt;img&gt;john_2.jpg&lt;/img&gt;&lt;/emp&gt;
      &lt;emp emp_name="john"&gt;&lt;img&gt;john_3.jpg&lt;/img&gt;&lt;/emp&gt;
      &lt;emp emp_name="marry"&gt;&lt;img&gt;marry_1.jpg&lt;/img&gt;&lt;/emp&gt;
      &lt;emp emp_name="marry"&gt;&lt;img&gt;marry_2.jpg&lt;/img&gt;&lt;/emp&gt;
      &lt;emp emp_name="david"&gt;&lt;img&gt;david_1.jpg&lt;/img&gt;&lt;/emp&gt;
  &lt;/emp_detail&gt;
  &lt;/all_emp&gt;
  </code></pre>
  
  <p>So, i was try, but in here i has problem:</p>
  
  <pre><code>function get_empimg() {
  $url = 'https://...emp_test.xml';
  $xml = simplexml_load_file("$url") or die("Error: Cannot create object");
  foreach($xml-&gt;children() as $emp_detail) {
      //do something in here;
      //return img has attribute is John
  } 
  </code></pre>
  
  <p>}</p>
  
  <p>How to pasre it to get all img with attribute is John?</p>
  
  <p>Thank you for reading!</p>