How to programmatically update an action in another macro?

Great!

From the link Peter provided.

His example that encodes ASCII text for XML using the Filter action with Encode HTML Entities is here:

Macro to Create a Text Expansion Macro from the Selected Text - Macro Library - Keyboard Maestro Discourse

FWIW I use this instead in a lot of my scripts that work with KM xml:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"

set unencodedText to "test¥&<me>\"'"

set encodedText to (current application's NSXMLNode's textWithStringValue:unencodedText)'s XMLString() as text
return encodedText
-->test¥&amp;&lt;me&gt;"'

It doesn't encode single and double quotes but I've not had a problem with that.

This version would do that:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"

set encodedText to (((current application's NSXMLNode's textWithStringValue:unencodedText)'s XMLString()'s stringByReplacingOccurrencesOfString:"'" withString:"&#x27;")'s stringByReplacingOccurrencesOfString:"\"" withString:"&quot;") as text
-->test¥&amp;&lt;me&gt;&quot;&#x27;
return encodedText
--> test¥&amp;&lt;me&gt;&quot;&#x27;
2 Likes