Or, use shrink tubing.
I just repaired my Ipad 2 frayed cord. I cut some shrink tubing I had laying around. I cut 1/2" shrink tubing length wise, and glued the ends together with Super Glue. Then shrink the tubing with heat.
It works better than I though it would.