1 |
#fraggleParserXML: Class for parsing XML from a stream or file |
#fraggleParserXML: Class for parsing XML from a stream or file |
2 |
|
|
3 |
import sys |
import sys |
4 |
|
import fraggleError |
5 |
|
|
6 |
from xml.dom.ext.reader import Sax2 |
from xml.dom.ext.reader import Sax2 |
7 |
from xml.marshal import * |
from xml.marshal import * |
8 |
|
|
20 |
|
|
21 |
|
|
22 |
def parseXML(self,input): |
def parseXML(self,input): |
23 |
dom = self.reader.fromStream(input) |
try: |
24 |
|
dom = self.reader.fromStream(input) |
25 |
|
except: |
26 |
|
fraggleError.errorFileNotFound() |
27 |
return dom |
return dom |
28 |
|
|
29 |
def printXML(self,inputDom,outputLocation): |
def printXML(self,inputDom,outputLocation): |
30 |
file = open(outputLocation,"w") |
try: |
31 |
self.reader.PrettyPrint(inputDom,file) |
file = open(outputLocation,"w") |
32 |
|
self.reader.PrettyPrint(inputDom,file) |
33 |
|
except: |
34 |
|
fraggleError.errorFileNotFound() |
35 |
|
|
36 |
def marshalXML(self,values,outputLocation): |
def marshalXML(self,values,outputLocation): |
|
file = open(outputLocation,"w") |
|
|
# self.marshall.dump(values,file) |
|
|
generic.dump(values,file) |
|
|
#print generic.dumps(values) |
|
37 |
|
try: |
38 |
|
file = open(outputLocation,"w") |
39 |
|
# self.marshall.dump(values,file) |
40 |
|
generic.dump(values,file) |
41 |
|
except: |
42 |
|
fraggleError.errorFileNotFound() |
43 |
|
|
44 |
|
|
45 |
|
#print generic.dumps(values) |
46 |
|
|
47 |
|
def unmarshalXML(self,inputLocation): |
48 |
|
try: |
49 |
|
file = open(inputLocation,"r") |
50 |
|
except: |
51 |
|
fraggleError.errorFileNotFound() |
52 |
|
return generic.load(file) |
53 |
|
|