Skip to content

Instantly share code, notes, and snippets.

@mark05e
Created April 25, 2024 19:55
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 mark05e/caa65534d3da2fbd7b42f11d35b19d22 to your computer and use it in GitHub Desktop.
Save mark05e/caa65534d3da2fbd7b42f11d35b19d22 to your computer and use it in GitHub Desktop.
XML to inContact Studio Multiline String

XML to inContact Studio Multiline String

Example

Input

<?xml version="1.0"?>
<note date="12/11/99">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

Output

datastring.append($"<?xml version=\"1.0\"?>{char(10)}")
datastring.append($"<note date=\"12/11/99\">{char(10)}")
datastring.append($"<to>Tove</to>{char(10)}")
datastring.append($"<from>Jani</from>{char(10)}")
datastring.append($"<heading>Reminder</heading>{char(10)}")
datastring.append($"<body>Don't forget me this weekend!</body>{char(10)}")
datastring.append($"</note>{char(10)}")

Debug Preview

image

Cyberchef Recipie

Deeplink Url

https://gchq.github.io/CyberChef/#recipe=Comment('Based%20on%20https://help.nice-incontact.com/content/studio/guide/datetimenumberformats.htm')Find_/_Replace(%7B'option':'Simple%20string','string':'%22'%7D,'%5C%5C%5C%5C%22',true,false,true,false)Find_/_Replace(%7B'option':'Simple%20string','string':'%5C''%7D,'%5C%5C%5C'',true,false,true,false)Find_/_Replace(%7B'option':'Simple%20string','string':'%7B'%7D,'%5C%5C%7B',true,false,true,false)Remove_whitespace(false,true,false,false,false,false)Pad_lines('Start',20,'datastring.append($%22')Pad_lines('End',12,'%7Bchar(10)%7D%22)')&input=PD94bWwgdmVyc2lvbj0iMS4wIj8%2BDQo8bm90ZSBkYXRlPSIxMi8xMS85OSI%2BDQo8dG8%2BVG92ZTwvdG8%2BDQo8ZnJvbT5KYW5pPC9mcm9tPg0KPGhlYWRpbmc%2BUmVtaW5kZXI8L2hlYWRpbmc%2BDQo8Ym9keT5Eb24ndCBmb3JnZXQgbWUgdGhpcyB3ZWVrZW5kITwvYm9keT4NCjwvbm90ZT4&ieol=CRLF

Chef Format

Comment('Based on https://help.nice-incontact.com/content/studio/guide/datetimenumberformats.htm')
Find_/_Replace({'option':'Simple string','string':'"'},'\\\\"',true,false,true,false)
Find_/_Replace({'option':'Simple string','string':'\''},'\\\'',true,false,true,false)
Find_/_Replace({'option':'Simple string','string':'{'},'\\{',true,false,true,false)
Remove_whitespace(false,true,false,false,false,false)
Pad_lines('Start',20,'datastring.append($"')
Pad_lines('End',12,'{char(10)}")')

JSON Format

[
  { "op": "Comment",
    "args": ["Based on https://help.nice-incontact.com/content/studio/guide/datetimenumberformats.htm"] },
  { "op": "Find / Replace",
    "args": [{ "option": "Simple string", "string": "\"" }, "\\\\\"", true, false, true, false] },
  { "op": "Find / Replace",
    "args": [{ "option": "Simple string", "string": "'" }, "\\'", true, false, true, false] },
  { "op": "Find / Replace",
    "args": [{ "option": "Simple string", "string": "{" }, "\\{", true, false, true, false] },
  { "op": "Remove whitespace",
    "args": [false, true, false, false, false, false] },
  { "op": "Pad lines",
    "args": ["Start", 20, "datastring.append($\""] },
  { "op": "Pad lines",
    "args": ["End", 12, "{char(10)}\")"] }
]

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment