forked from brumar/manipsXML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyCanevasReader.py
38 lines (30 loc) · 1.05 KB
/
myCanevasReader.py
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
34
35
36
37
import xml.etree.ElementTree as ET
import string
xmlFile="canev.xml"
class CanevasDic():
def __init__(self):
self.markerDic={}
self.matchingTextDic={}
self.idstyle={}
def addmarker(self,marker,element,idStyle):
self.markerDic[marker]=[element,idStyle]
def addcode(self,code,element,idStyle):
self.matchingTextDic[code]=[element,idStyle]
def addId(self,code, element,idStyle):
self.idstyle[idStyle]=element
def read(self,xmlFile):
root=ET.parse(xmlFile).getroot()
for canev in root:
code=canev.find("text").get("code")
marker=canev.find("marker").get("markerId")
element=canev.find("styleXmind")
idStyle=canev.find("styleXmind").find("style").get("id")
self.addcode(code, element,idStyle)
self.addmarker(marker, element,idStyle)
self.addId(code, element, idStyle)
if __name__=="__main__":
c=CanevasDic()
c.read(xmlFile)
print(c.markerDic)
print(c.matchingTextDic)
print(c.idstyle)