<TreeRoot> <Switch1> <id>1</id> <ip>10.0.0.1</ip> <hostname>zyxel</hostname> <description>misowskaja</description> <templateswitch>zyxel</templateswitch> <icmp>fail</icmp> </Switch1> <Switch2> <id>2</id> <ip>10.0.0.2</ip> <hostname>zyxel</hostname> <description>misowskaja2</description> <templateswitch>zyxel</templateswitch> <icmp>fail</icmp> </Switch2> </TreeRoot>
XML_FILE = 'xmlfile.xml' tree = ET.parse(XML_FILE) root = tree.getroot() tag = [] text = [] start = 0 end = 7 for elem in root.getiterator(): if elem.tag == "TreeRoot": continue tag.append(elem.tag) text.append(elem.text) print '<table border="2px" width="100%">' for x in tag: if x.startswith('Sw'): print '<tr>' print '<td rowspan="2">', x, '</td>' elif x.endswith('icmp'): print '<th>', x, '</th></tr>' print '<tr>' for y in text[start:end]: if y == '\n ': start += 1 end += 1 continue print '<td>', y, '</td>' start += 1 end += 1 print '</tr>' else: print '<th>', x, '</th>' print '</table>'

А нужно так

PS:Реализовать нужно логику, а не оформление. И как еще что бы при клики мышки по полю у меня отправляло на обработчик в который будет отправляться текущий ip, либо сделать дополнительное поле\кнопку при нажатии на которую будет перекидывать на обработчик. А дальше я уже буду подключатся по snmp и манипулировать свичем