Derek ,
the railway company here in Spain is called RENFE ... you can book on-line on their website :
http://www.renfe.es/horarios/english/index.html The strange thing that I discovered was that the front page is in English but when you opt to buy a ticket on-line it then is only in Spanish . Do you speak Spanish ? Anyway I booked my ticket to Malaga and , much like an airline , you can print your ticket off straight away .
Bear in mind that since the Atocha bombing atrocity here in Madrid , Security has been escalated in railway stations and your baggage will almost certainly go through security screening before you reach the platform .
The AVE is spectacularly punctual .. As a previous post mentioned , on some routes you'll get your money back if it's 5 minutes late !! UK rail services PLEASE take note !
Steve