I'm using python to create XML files to automate a workflow.
The code I have written is:
from xml.dom import minidom
import os
root = minidom.Document()
xml = root.createElement('WASATCH') #main (root) element
xml.setAttribute("ACTION","JOB")
#Create XML File
xml_str = root.toprettyxml(encoding='utf-8',indent="\t")
xml_file = "EXAMPLE.xml" #name xml file
with open(xml_file, "wb") as f:
f.write(xml_str)
currently the code prints quotes around JOB
<WASATCH ACTION="JOB">
but I need those removed to just print this
<WASATCH ACTION=JOB>
what can I do to remove the quotes around JOB?
Removing quotes will make it invalid xml. If you really want that, take xml_str and replace quotes by your method of choice, e.g.
new = xml_str.replace(‘“‘,’’)