mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
Question/Feature: Add support for selecting XPath in response template #239
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kashifsoofi on GitHub (Jan 8, 2020).
Originally assigned to: @StefH, @kashifsoofi on GitHub.
Hi,
I am looking to transform soap response. And it would be good if i can use the XPath to select values from request. I believe it can be done using regex but XPath would be a natural fit for this use case.
Question: Is it already supported?
If not happy to do a PR. It would be similar to how json template work.
"{{XPath.Select request.body "/todo-list/todo-item[1]/text()"}}") to return text of 1st element in response.
@StefH commented on GitHub (Jan 8, 2020):
This is not yet supported, this could be a valuable addition.
Suggested 2 methods:
XPath.SelectSingleNodeXPath.SelectNodesI'll take a look at the code how to implement this.
@kashifsoofi commented on GitHub (Jan 8, 2020):
I am happy to do a PR for this if okay.
@StefH commented on GitHub (Jan 8, 2020):
You can make a PR. For reference see the https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Transformers/HandleBarsJsonPath.cs file.
Also make sure to add unit-tests for this new transformer. For reference, see https://github.com/WireMock-Net/WireMock.Net/blob/master/test/WireMock.Net.Tests/ResponseBuilders/ResponseWithHandlebarsJsonPathTests.cs