Asking just because I'm curious... why are you using xpath?
Also, is this for a website you control or for some else's website?
If you're rendering the page (in a browser, e2e test-runner, spider bot, etc...), have you considered running some js on the page to get the image? Something like: const imagePath = document.getElementById('exampleIdOnElement').style.backgroundImage