title: PHP/SimpleXML/XPath get attribute value by another attribute in same element
body: <p>I have this XML (from a pptx file):</p>
  
  <pre><code>&lt;Relationships&gt;
      &lt;Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image2.png"/&gt;
      &lt;Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image1.wmf"/&gt;
      &lt;Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/&gt;
  &lt;/Relationships&gt;
  </code></pre>
  
  <p>I want to pull the <em>Target</em> attribute from a <em>Relationship</em> element, and I know the <em>Id</em> value.</p>
  
  <p>I could do it with SimpleXML if I iterate through the nodes (<a href="https://stackoverflow.com/questions/14979588/selecting-attribute-values-based-on-another-attribute-value-with-simplexml">like this question</a>)</p>
  
  <pre><code>$resxml = simplexml_load_file('zip://my.pptx#ppt/slides/_rels/slide1.xml.rels');
  echo $resxml-&gt;Relationship[0]-&gt;attributes()-&gt;Target;
  </code></pre>
  
  <p>But I would like to get it using xpath <a href="https://stackoverflow.com/questions/992450/simplexml-selecting-elements-which-have-a-certain-attribute-value">using this sort of idea</a>.  Whatever I do in xpath returns an empty object when I search for something like 'rId3'. I thought it would be the below xpath statement, but it returns an empty object.  I have tried about 50 combimations and found a lot of similar but not identical issues when searching:</p>
  
  <pre><code>$image = $resxml-&gt;xpath("/Relationships/Relationship[@Id='rId3']/@Target"); 
  print_r($image);
  </code></pre>
  
  <p>I guess I will just end up iterating through all the nodes but it seems inefficient.  My server appears to have XPath in the Dom available and SimpleXML enabled.</p>