/[cvs]/nfo/projects/netfraggle/bin/fraggleParserXML.py
ViewVC logotype

Diff of /nfo/projects/netfraggle/bin/fraggleParserXML.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by xabbu, Wed Aug 25 13:53:48 2004 UTC revision 1.4 by xabbu, Thu Aug 26 23:10:12 2004 UTC
# Line 1  Line 1 
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 generic  from xml.marshal import *
8    
9  def create(parent):  def create(parent):
10      return fraggleParserXML()      return fraggleParserXML(parent)
11            
12  class fraggleParserXML:  class fraggleParserXML:
13      def __init_reader__():      def __init_reader__(self):
14          reader = Sax2.Reader()         self.reader = Sax2.Reader()
15          marshall = generic.Marshaller()      
16                    
17      def __init__(self,parent):      def __init__(self,parent):
18          self.__init_reader__()          self.__init_reader__()
19                    
20                    
21            
22      def parseXML(input):      def parseXML(self,input):
23          dom = self.reader.fromStream(input)          try:
24                dom = self.reader.fromStream(input)
25            except:
26                fraggleError.errorXMLStreamNotValid()
27          return dom          return dom
28            
29      def printXML(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(outputLocation)
35                
36        def marshalXML(self,values,outputLocation):
37            try:
38                file = open(outputLocation,"w")
39               # self.marshall.dump(values,file)
40                generic.dump(values,file)
41            except:
42                fraggleError.errorFileNotFound(outputLocation)
43                    
     def marshalXML(value,outputLocation):  
         file = open(outputLocation,"w")  
         marshall.dump(value,file)  
           
           
44                    
45            #print generic.dumps(values)
46        
47        def unmarshalXML(self,inputLocation):
48            try:
49                file = open(inputLocation,"r")
50            except:
51                fraggleError.errorFileNotFound(inputLocation)
52            return generic.load(file)
53        

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed