I would like to know if is it possible (compatible) to use the same cable of a 3.5" HDD for a 2.5" SSD, or in other words, just swap one for another?
Yes this is possible. However, going from a 2.5 to a 3.5 if you're using a laptop will not work, because a 3.5" won't fit.
*NOTE Make sure both connections are SATA or IDE. If they are not, then they are not compatible. The picture shows the difference between the two.