Yep, everything you've suggested here should be possible and fairly straightforward.
1. To create a new unit promotion class you need to add that promotion class to the 'Types' table. For anti-cavalry that looks like this:
<Types>
<Row Type="PROMOTION_CLASS_ANTI_CAVALRY" Kind="KIND_PROMOTION_CLASS"/>
</Types>
You should replace the "PROMOTION_CLASS_ANTI_CAVALRY" with the name of your new promotion class. Next you want to add the ability class to the 'Tags' and 'TypeTags' tables along with any ability you want to apply to the whole units class. Anti-cavalry and their bonus against cavalry looks like this:
<Tags>
<Row Tag="CLASS_ANTI_CAVALRY" Vocabulary="ABILITY_CLASS"/>
</Tags>
<TypeTags>
<Row Tag="CLASS_ANTI_CAVALRY" Type="ABILITY_ANTI_CAVALRY"/>
</TypeTags>
There are a few other things to consider, but for a start, adding in your new promotion class and any abilities like this should create the new unit class. As for creating new promotions for that promotion class, I'd recommend just copying the promotions from another class for starters. But if you know how, you can also add completely new promotions too.
2. To get musketmen and Pike&Shot to upgrade into your new unit, you want to change the 'UnitUpgrades' table.
<UnitUpgrades>
<Update><Where Unit="UNIT_MUSKETMAN"/><Set UpgradeUnit="UNIT_LINE_INFATRY"/></Update>
<Update><Where Unit="UNIT_PIKE_AND_SHOT"/><Set UpgradeUnit="UNIT_LINE_INFATRY"/></Update>
</UnitUpgrades>
Just replace the 'UNIT_LINE_INFATRY' with the technical name of you new unit. It's important to use the "Update" XML syntax to replace the default upgrade with your new unit. Keep in mind that any unit that gets upgraded into a new promotion class keeps all of the promotions from its old promotion class. So a pike and shot might keep the "Thrust" promotion even if line infantry aren't eligible to get that promotion. That could be a bug or a feature depending on how you look at it.
3. To make certain units good against tanks but not horsemen, you would add to or change the 'TypeTags' table again. First you would want to tell the game which units are tanks and which are horsemen:
<Tags>
<Row Tag="CLASS_HORSEMAN" Vocabulary="ABILITY_CLASS"/>
<Row Tag="CLASS_TANK Vocabulary="ABILITY_CLASS"/>
</Tags>
<TypeTags>
<Row Tag="CLASS_HORSEMAN" Type="UNIT_KNIGHT"/>
<Row Tag="CLASS_TANK " Type="UNIT_TANK"/>
</TypeTags>
You want to do that for all units that you think are relevant. Next you would probably want to delete the "ABILITY_ANTI_CAVALRY" and replace it with two new abilities: "ABILITY_ANTI_HORSE" and "ABILITY_ANTI_TANK", for example line infantry could be good against both:
<Tags>
<Row Tag="CLASS_ANTI_HORSEMAN" Vocabulary="ABILITY_CLASS"/>
<Row Tag="CLASS_ANTI_TANK Vocabulary="ABILITY_CLASS"/>
</Tags>
<TypeTags>
<Row Tag="CLASS_ANTI_HORSEMAN" Type="UNIT_LINE_INFANTRY"/>
<Row Tag="CLASS_ANTI_TANK " Type="UNIT_LINE_INFANTRY"/>
</TypeTags>
These tags won't actually do anything yet, for that you have to create the relevant abilities, and that is a bit more complicated.
In general, my advice would be to play around with
this website and copy this as closely as you can from the base game. But in general I hope this is enough info to get started. Let me know if you run into any trouble and I'd be happy to help.