This is more often true when you never know what would be the id in simple terms if the value is dynamic & changes for every request.
Let's take a shopping cart example:
1. When we add items to the cart we never know what forms a cartId,if we have to pass that cartId to the basket.
So let's extract the value of Id by passing a xpath query to search for the name "cartId" - This can be determined either by firebug if you are on firefox or debugbar if you are on Internet explorer.
2.Add a debug sampler so that you will know what is returned in the variable you stored.
3.How do we add a XPATH Extractor to our HTTP request.
3.a Right Click the HTTP request
3.b Click on Add >> Post Processors > Xpath Extractor

4. Let's have a closer look at the XPATH Extractor.

4.a Give a name to the xpath extractor.
4.b Check the Use Tidy and the Quiet
4.c Add Reference name - It is like a variable name
4.d Pass the Xpath query
4.e Pass the default value it will displayed if there is no value being fetched from the query.