Skip to content

Instantly share code, notes, and snippets.

@ahmed-abdelazim
Last active March 10, 2020 12:15
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 ahmed-abdelazim/05982cd11303e748a81f0bb50574b0ad to your computer and use it in GitHub Desktop.
Save ahmed-abdelazim/05982cd11303e748a81f0bb50574b0ad to your computer and use it in GitHub Desktop.
convert XML files to format can be posted via postman
import os
if not os.path.exists('escaped'):
os.makedirs('escaped')
def escape(file):
with open(file, 'r') as f:
a_string = ''.join(f)
escaped = a_string.replace('"', '\\"')
escaped = escaped.replace('><', '>\\r\\n<')
file_escaped = './escaped/'+file
f = open(file_escaped, "w")
f.write(escaped)
print(escaped)
files = [f for f in os.listdir('.') if f.endswith('.xml') or f.endswith('.XML')]
for file in files:
escape(file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment