Last active
March 10, 2020 12:15
-
-
Save ahmed-abdelazim/05982cd11303e748a81f0bb50574b0ad to your computer and use it in GitHub Desktop.
convert XML files to format can be posted via postman
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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