I am working with the shopify item feed xml which has items and image separated. I'd like to get an item's image url with a single xpath. The xml looks something like this-
<products>
<product>
<variants>
<variant>
<image-id>123</image-id>
</variant>
</variants>
</product>
<images>
<image>
<id>123</id>
<src>https://abc/</src>
</image>
</images>
</products>
My starting point is within the variant. So to get to the image I can go up two parents, down into images, fetch the image with the matching id, then get the src from that element.
parent::*/parent::*/images/image[id/text()="123"]/src/text()
This works, but it's hard coded to "123". What i'd like is to take the image-id text from the variant and use that as the predicate value.
parent::*/parent::*/images/image[id/text()=image-id/text()]/src/text()
XPath at least doesn't complain about this, but it doesn't work as I was hoping. Is it possible to use the value from image-id/text() as the predicate value for id/text()= ?
./../../images/image[id = ./../../product/variants/variant/image-id]/src/text()