247
|
1 import xml.dom.minidom
|
|
2 #from xml.dom import utils
|
|
3 from xml.dom.minidom import parseString
|
|
4 import urllib
|
|
5
|
|
6 def zUrlopenRead(self,url):
|
|
7 return urllib.urlopen(url).read()
|
|
8
|
|
9 def zUrlopenInfo(self,url):
|
|
10 return urllib.urlopen(url).info()
|
|
11
|
|
12 def zUrlopenParseString(self,string):
|
|
13 return parseString(string)
|
|
14
|
|
15 def zUrlopenDocumentElement(self,doc):
|
|
16 return doc.documentElement
|
|
17
|
|
18 def zUrlopenChildNodes(self,docnode):
|
|
19 return docnode.childNodes
|
|
20
|
|
21 def zUrlopenGetElementsByTagName(self,docnodelist,name):
|
|
22 return docnodelist.getElementsByTagName(name)
|
|
23
|
|
24 def zUrlopenLength(self,docnodelist):
|
|
25 return docnodelist.length
|
|
26
|
|
27 def zUrlopenGetItem(self,docnodelist,number):
|
|
28 return docnodelist.item(number)
|
|
29
|
|
30 def zUrlopenGetAttribute(self,docnode,name):
|
|
31 return docnode.getAttribute(name)
|
|
32
|
|
33 def zUrlopenGetTextData(self,docnode):
|
|
34 # return docnode.nodeName
|
|
35 return getText(docnode.childNodes)
|
|
36
|
|
37 def getText(nodelist):
|
|
38 rc = ""
|
|
39 for node in nodelist:
|
|
40 if node.nodeType == node.TEXT_NODE:
|
|
41 rc = rc + node.data
|
|
42 return rc
|
|
43
|
|
44
|
|
45
|