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

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.5

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