I wouldn`t take the bus or the train, because both parks are in an opposite direction of Hamburg. Each about 100 KM ( 1-way). Traveling by car cost not so mutch time and you can start direct at the airport.
If you want to go by bus or train, you have first take a bus and a train to the centralstation of Hamburg. Only here starts the train to Hansapark and next to the centralstation is the ZOB ( central bus station ) for the bus to Heidepark.
If you need help, feel free to send me an email.