I read that you can take a night train from Belgrade to Zagreb (and I confirmed it in the DB website), but it first goes to Budapest, transfers, and then goes to Zagreb. I also know there's a direct train but I rather want to take the night train in order to save on the accommodation cost.
In this case, is the transit in Budapest handled as a one-day stay in the Schengen area? Or is it like a flight and there's no need to get through immigration?