23 lines
636 B
Python
23 lines
636 B
Python
#!/usr/bin/python3
|
|
|
|
import lxml.etree
|
|
from lxml.etree import _Element
|
|
from typing import Counter
|
|
import json
|
|
import collections
|
|
|
|
file_name = "3"
|
|
|
|
with open("{:}.json".format(file_name)) as f:
|
|
xml_str: str = json.load(f)["AT"]
|
|
root: _Element = lxml.etree.fromstring(xml_str)
|
|
with open("{:}.xml".format(file_name), "w") as f:
|
|
f.write(lxml.etree.tostring(root, encoding="unicode", pretty_print=True))
|
|
#root: _Element = lxml.etree.parse("{:}.xml".format(file_name)).getroot()
|
|
node_types: Counter[str] = collections.Counter()
|
|
for n in root.iter():
|
|
node_types[n.tag] += 1
|
|
|
|
for n in sorted(node_types):
|
|
print(n, node_types[n])
|