Stopping on the way to a destination train tickets

Hi everyone so I'm going in a few weeks very exciting!

But I have a couple days where I'm taking a train a couple of hours to some destinations. However en route there are some really nice looking city's I think it might be worth stopping over for a couple hours maybe getting lunch having a wonder around. What do I need to buy as a ticket? To that destination in advance? Can I buy it to the final one and just stop off if I like the look then back on with the same ticket ?

by Narcuga