I have this XML (from a pptx file):
<Relationships>
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image2.png"/>
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image1.wmf"/>
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>
</Relationships>
I want to pull the Target attribute from a Relationship element, and I know the Id value.
I could do it with SimpleXML if I iterate through the nodes (like this question)
$resxml = simplexml_load_file('zip://my.pptx#ppt/slides/_rels/slide1.xml.rels');
echo $resxml->Relationship[0]->attributes()->Target;
But I would like to get it using xpath using this sort of idea. 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:
$image = $resxml->xpath("/Relationships/Relationship[@Id='rId3']/@Target");
print_r($image);
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.