Install the flange support
If only the area directly below the flange is rotted, you can install a two-piece steel closet flange support. It goes under the flange and transfers the load of the flange and toilet (and you) out onto more solid surrounding wood. But if your floor is severely rotted, say more than an inch beyond the flange, you're stuck replacing the flooring around the toilet.
Flange supports are available at home centers and plumbing supply stores for either cast iron, plastic or brass flanges.