title: xml file from excel sheet data
body: <p>Hello using the code snippet below, I created an xml below, but I notice that: the parameter order I use in the code is different from that in the output i.e. <code>&lt;node y="-3749099.0" x="-45194.0" id="11542.0"/&gt;</code> should be  <code>&lt;node id="11542.0"  x="-45194.0" y="-3749099.0"/&gt;</code> also the output is not as the desired output below. Can someone advise how I can: </p>
  
  <ul>
  <li>correct my code to get the correct output</li>
  <li>extend the code so that if I had to use an excel file with many columns (more than 3) I wont have to hard code <code>val[0], val[1], val[2]</code> as in <code>FIELD(id=str(val[0]), x=str(val[1]), y=str(val[2])),</code> </li>
  </ul>
  
  <p>Code Snippet:</p>
  
  <pre><code>import lxml.etree
  import lxml.builder
  import xlrd
  
  wb = xlrd.open_workbook("emme_nodes1.xls")
  sh = wb.sheet_by_index(0)
  tags = [n.replace(" ", "").lower() for n in sh.row_values(0)]
  
  for row in range(1, sh.nrows):
      val = sh.row_values(row)
  
      E = lxml.builder.ElementMaker()
      ROOT = E.network
      DOC = E.nodes
      FIELD = E.node
      my_doc = ROOT(
              DOC(
                  FIELD(id=str(val[0]), x=str(val[1]), y=str(val[2])),
                  )
              )
      print lxml.etree.tostring(my_doc, pretty_print=True)
  </code></pre>
  
  <p>Output:
      
        
          
        
      </p>
  
  <pre><code>&lt;network&gt;
    &lt;nodes&gt;
      &lt;node y="-3748681.0" x="-45333.0" id="11543.0"/&gt;
    &lt;/nodes&gt;
  &lt;/network&gt;
  
  &lt;network&gt;
    &lt;nodes&gt;
      &lt;node y="-3747847.0" x="-44369.0" id="11540.0"/&gt;
    &lt;/nodes&gt;
  &lt;/network&gt;
  
  &lt;network&gt;
    &lt;nodes&gt;
      &lt;node y="-3748683.0" x="-45060.0" id="11541.0"/&gt;
    &lt;/nodes&gt;
  &lt;/network&gt;
  
  &lt;network&gt;
    &lt;nodes&gt;
      &lt;node y="-3750248.0" x="-45518.0" id="11546.0"/&gt;
    &lt;/nodes&gt;
  &lt;/network&gt;
  
  &lt;network&gt;
    &lt;nodes&gt;
      &lt;node y="-3750024.0" x="-45448.0" id="11547.0"/&gt;
    &lt;/nodes&gt;
  &lt;/network&gt;
  
  &lt;network&gt;
    &lt;nodes&gt;
      &lt;node y="-3749821.0" x="-44745.0" id="11544.0"/&gt;
    &lt;/nodes&gt;
  &lt;/network&gt;
  
  &lt;network&gt;
    &lt;nodes&gt;
      &lt;node y="-3750508.0" x="-45561.0" id="11545.0"/&gt;
    &lt;/nodes&gt;
  &lt;/network&gt;
  
  &lt;network&gt;
    &lt;nodes&gt;
      &lt;node y="-3750202.0" x="-45802.0" id="11548.0"/&gt;
    &lt;/nodes&gt;
  &lt;/network&gt;
  
  &lt;network&gt;
    &lt;nodes&gt;
      &lt;node y="-3749805.0" x="-45485.0" id="11549.0"/&gt;
    &lt;/nodes&gt;
  &lt;/network&gt;
  </code></pre>
  
  <p>Desired Output:</p>
  
  <pre><code>&lt;network&gt;
    &lt;nodes&gt;
      &lt;node id="11542.0" x="-45194.0" y="-3749099.0"/&gt;
      &lt;node id="11543.0" x="-45333.0" y="-3748681.0"/&gt;
      &lt;node id="11540.0" x="-44369.0" y="-3747847.0"/&gt;
      &lt;node id="11541.0" x="-45060.0" y="-3748683.0"/&gt;
      &lt;node id="11546.0" x="-45518.0" y="-3750248.0"/&gt;
      &lt;node id="11547.0" x="-45448.0" y="-3750024.0"/&gt;
      &lt;node id="11544.0" x="-44745.0" y="-3749821.0"/&gt;
      &lt;node id="11545.0" x="-45561.0" y="-3750508.0"/&gt;
      &lt;node id="11549.0" x="-45485.0" y="-3749805.0"/&gt;
      &lt;node id="11548.0" x="-45802.0" y="-3750202.0"/&gt;
      &lt;node id="11549.0" x="-45485.0" y="-3749805.0"/&gt;
    &lt;/nodes&gt;
  &lt;/network&gt;
  </code></pre>
  
  <p>Excel sheet (emme_nodes1.xls): </p>
  
  <pre><code> id         x           y
  11542   -45194.0    -3749099.0
  11543   -45333.0    -3748681.0
  11540   -44369.0    -3747847.0
  11541   -45060.0    -3748683.0
  11546   -45518.0    -3750248.0
  11547   -45448.0    -3750024.0
  11544   -44745.0    -3749821.0
  11545   -45561.0    -3750508.0
  11548   -45802.0    -3750202.0
  11549   -45485.0    -3749805.0
  </code></pre>