diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-11-03 05:24:44 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-11-03 05:24:44 +0300 |
commit | ab6260a9a1abb6457d38b1257976f8ea547a8a13 (patch) | |
tree | 307602fde6cded0a183e157673b839ef110382ba |
-rwxr-xr-x | fgis-egrn-parse-xml.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/fgis-egrn-parse-xml.py b/fgis-egrn-parse-xml.py new file mode 100755 index 0000000..5b30274 --- /dev/null +++ b/fgis-egrn-parse-xml.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +from argparse import ArgumentParser +from xml.dom import minidom + + +if __name__ == '__main__': + parser = ArgumentParser() + parser.add_argument('--input', '-i', dest='input', required=True, type=str, + help='input xml file') + arg = parser.parse_args() + + with open(arg.input, 'r') as f: + doc = minidom.parseString(f.read()) + + try: + obj = doc.getElementsByTagName('Parcel')[0] + except IndexError: + obj = doc.getElementsByTagName('Building')[0] + + num = obj.getAttribute('CadastralNumber') + print(num) + + owners = doc.getElementsByTagName('Owner') + if not owners: + util = doc.getElementsByTagName('Utilization')[0].getAttribute('ByDoc') + print('? ' + util) + else: + for o in owners: + for person in o.getElementsByTagName('Person'): + print('- ' + person.getElementsByTagName('Content')[0].firstChild.nodeValue) + for org in o.getElementsByTagName('Organization'): + print('- ' + org.getElementsByTagName('Content')[0].firstChild.nodeValue) |