-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXML Parser.py
More file actions
33 lines (25 loc) · 796 Bytes
/
XML Parser.py
File metadata and controls
33 lines (25 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import xml.dom.minidom as md
import pandas as pd
cfg = md.parse("cfg.xml");
MOs = cfg.getElementsByTagName("managedObject")
print("%d MOs: " % MOs.length)
panda = pd.DataFrame(columns=('object','dn'))
i = 0
for MO in MOs:
data = [MO.getAttribute("class"),MO.getAttribute("distName")] + [parameter.firstChild.data for parameter in MO.getElementsByTagName("p")]
columns = ['object','dn'] + [parameter.getAttribute("name") for parameter in MO.getElementsByTagName("p")]
temp = pd.DataFrame(columns = columns)
temp.loc[0] = data
# try:
panda = panda.append(temp, ignore_index = True)
# except:
# pass
i += 1
print(i)
# if i == 100: break
print(panda.head())