Here is a macro for creating a new text expansion macro from the selected text. Select the desired text, trigger the macro (by default it is with a Status Menu trigger, adjust as desired), enter the trigger text when prompted and the macro will be created.
Updated using version 8.x AppleScript facilities.
Note that although it attempts to encode the HTML entities, the requirement is that it actually be XML entities, and so it will not necessarily work well for non-ASCII text.
Create Text Expansion From Selection.kmmacros (4.7 KB)
(Old version for pre-8.x: Create Text Expansion From Selection.kmmacros (5.3 KB))