title: JSON to XML File using Python
body: <p>I am trying to convert one big <code>JSON</code> file to a <code>XML</code> file. Below are the two lines which i took out from a big JSON. I am trying to create a root node for every INVENTORY_SEQ_ID present in this file:</p>
  
  <pre><code>[{"INVENTORY_SEQ_ID":4577494,"GROUP_NBR":8605548,"SEQ_NBR":300,"FACILITY_CODE":"OCALADC","COMPANY_CODE":"AMES"},
  {"INVENTORY_SEQ_ID":4577495,"GROUP_NBR":8605548,"SEQ_NBR":301,"FACILITY_CODE":"OCALADC","COMPANY_CODE":"AMES"}]
  </code></pre>
  
  <p>I have written below code (I am just a beginner in this field) and it works if there is only one Row in the JSON file. It throw an error if there are more thab one.</p>
  
  <pre><code>import json as j
  with open("invdata.json") as input_var:
   d=j.load(input_var)
  import xml.etree.cElementTree as e
  r=e.Element("InvHead")
  e.SubElement(r,"INVENTORY_SEQ_ID").text = str(d["INVENTORY_SEQ_ID"])
  e.SubElement(r,"GROUP_NBR").text = str(d["GROUP_NBR"])
  e.SubElement(r,"SEQ_NBR").text = str(d["SEQ_NBR"])
  e.SubElement(r,"FACILITY_CODE").text = d["FACILITY_CODE"]
  e.SubElement(r,"COMPANY_CODE").text = d["COMPANY_CODE"]
  a=e.ElementTree(r)
  a.write("output.xml")
  </code></pre>
  
  <p>Any help is deeply appreciated.</p>
  
  <p>Thanks
  ANmol</p>