| 1 |
xabbu |
1.1 |
#fraggleParserXML: Class for parsing XML from a stream or file |
| 2 |
|
|
|
| 3 |
|
|
import sys |
| 4 |
|
|
from xml.dom.ext.reader import Sax2 |
| 5 |
xabbu |
1.2 |
from xml.marshal import * |
| 6 |
xabbu |
1.1 |
|
| 7 |
|
|
def create(parent): |
| 8 |
xabbu |
1.2 |
return fraggleParserXML(parent) |
| 9 |
xabbu |
1.1 |
|
| 10 |
|
|
class fraggleParserXML: |
| 11 |
xabbu |
1.2 |
def __init_reader__(self): |
| 12 |
|
|
self.reader = Sax2.Reader() |
| 13 |
|
|
|
| 14 |
xabbu |
1.1 |
|
| 15 |
|
|
def __init__(self,parent): |
| 16 |
|
|
self.__init_reader__() |
| 17 |
|
|
|
| 18 |
|
|
|
| 19 |
|
|
|
| 20 |
xabbu |
1.2 |
def parseXML(self,input): |
| 21 |
xabbu |
1.1 |
dom = self.reader.fromStream(input) |
| 22 |
|
|
return dom |
| 23 |
|
|
|
| 24 |
xabbu |
1.2 |
def printXML(self,inputDom,outputLocation): |
| 25 |
xabbu |
1.1 |
file = open(outputLocation,"w") |
| 26 |
|
|
self.reader.PrettyPrint(inputDom,file) |
| 27 |
|
|
|
| 28 |
xabbu |
1.2 |
def marshalXML(self,values,outputLocation): |
| 29 |
xabbu |
1.1 |
file = open(outputLocation,"w") |
| 30 |
xabbu |
1.2 |
# self.marshall.dump(values,file) |
| 31 |
|
|
generic.dump(values,file) |
| 32 |
|
|
#print generic.dumps(values) |