I have the following XML file
-
...
...
Realtive to your context node $item (I have no doubt there's why you need that context node ;-)) you're looking for ImageSet that a) is a child of ImageSets (which in turn is a direct child of your context node) and b) has the attribute Category with the value primary
(which you have coded correctly)
xpath('ImageSets/ImageSet[@Category="primary"]') as $p) {
echo $p->SwatchImage->URL;
}
}
function data() {
return <<< eox
-
...
...
...
...
primary swatch image url
...
- ...
eox;
}