       $ 'tbody', {key}, [
         $ 'tr', {key: key+'-_inner-td'}, node.children.map (cell, i) ->
           k = key+'-td'+i
-          $ 'td', {key: k, style: {textAlign: tableAlign ? 'left'}}, toChildren(cell, k)
+          $ 'td', {key: k, style: {textAlign: tableAlign[i] ? 'left'}}, toChildren(cell, k)
       ]
     when 'tableCell'   then $ 'span', {key}, toChildren(node, key)
 


toChildren = (node, parentKey, tableAlign = []) ->
  return (for child, i in node.children
    align = tableAlign[i]
    compile(child, parentKey+'_'+i, align))

parser = new DOMParser()
isInvalidXML = (xmlString) ->

      $ 'thead', {key}, [
        $ 'tr', {key: key+'-_inner-tr'}, node.children.map (cell, i) ->
          k = key+'-th'+i
          $ 'th', {key: k, style: {textAlign: tableAlign[i] ? 'left'}}, toChildren(cell, k)
      ]

    when 'tableRow'
