blob: 0828cb19d0a33111a911661f5011dad12a3c165d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import libxml2
fh = open("sitetest.xml")
input = libxml2.inputBuffer(fh)
reader = input.newTextReader("")
sites = {}
reader.Read()
siteID = ""
while reader.Read():
if reader.Name() == "site":
siteID = reader.GetAttribute("id")
sites[siteID] = {}
if reader.Name() in ("datetime", "name", "locname", "latitude", "longitude", "website", "access"):
print "found " + reader.Name() + " node"
sites[siteID][reader.Name()] = reader.ReadInnerXml()
print sites
|