Skip to content

Instantly share code, notes, and snippets.

@davidsheardown
Created April 28, 2023 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsheardown/34449353f9786c9515348c3c8a18c290 to your computer and use it in GitHub Desktop.
Save davidsheardown/34449353f9786c9515348c3c8a18c290 to your computer and use it in GitHub Desktop.
Decode or Encode XML where you are working with < or > sort of thing
Public Function DecodeXml(TextToDecode As String) As String
'Take text that has been encoded for XML and change it to normal text
Dim Res As String
Res = Replace(Replace(Replace(Replace(TextToDecode, "&quot;", """"), "&gt;", ">"), "&lt;", "<"), "&amp;", "&")
DecodeXml = Res
End Function
Public Function EncodeXml(TextToEncode As String) As String
'Take text and change special chars so that it can be included in an XML file
Dim Res As String
Res = Replace(Replace(Replace(Replace(TextToEncode, "&", "&amp;"), ">", "&gt;"), "<", "&lt;"), """", "&quot;")
EncodeXml = Res
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment