import xml.etree.ElementTree as ET
import sys, re
def stripNS(tag):
return re.sub("^\{.+\}","",tag)
def compact(node,indent):
if node==None:return
if ET.iselement(node):
localname = stripNS(node.tag)
sys.stdout.write(localname+'[')
indent += (len(localname)+1)*" "
attrs = node.attrib
first=True
for name in attrs:
if not first:sys.stdout.write(indent)
sys.stdout.write('@%s[%s)'%(name,attrs.get(name)))
first=False
if node.text and len(node.text.strip())>0:
sys.stdout.write(node.text.strip())
first=False
for child in list(node):
if not first: sys.stdout.write(indent)
compact(child,indent)
first=False
if child.tail and len(child.tail.strip())>0:
sys.stdout.write(indent+child.tail.strip())
sys.stdout.write(']')
compact(ET.parse(sys.stdin).getroot(),"\n")
sys.stdout.write('\n')