ver Mar10th

changed AT element filtering
This commit is contained in:
David Chang
2024-03-10 18:03:02 +08:00
parent ce23f3dab4
commit f08fa4912c
7 changed files with 322 additions and 37 deletions

View File

@@ -0,0 +1,22 @@
#!/usr/bin/python3
import lxml.etree
from lxml.etree import _Element
from typing import Counter
import json
import collections
file_name = "w0"
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])