I have two parallel inheritance chains:

Vehicle <- Car
        <- Truck <- etc.

VehicleXMLFormatter <- CarXMLFormatter
                    <- TruckXMLFormatter <- etc.

My experience has been that parallel inheritance hierarchies can become a maintenance headache as they grow.

i.e. NOT adding toXML(), toSoap(), toYAML() methods to my principal classes.

How do I avoid a parallel inheritance hierarchy without breaking the concept of separation of concerns?

Edit
Report