[XML-SIG] Interested in feedback

Robin Becker robin@jessikat.co.uk
Tue, 27 Jun 2000 11:41:09 +0100

In article <Pine.LNX.4.21.0006262312300.25151-200000@loki.appliedtheory.com>, Benjamin Saller
<case@appliedtheory.com> writes
>I am not really sure how to prefix this. I have something that is while
>not general purpose does seem simple to use in the 80% case. If people
>disagree, or can think of things that might make this better I would like
>some feedback.
I like this a lot. I changed the parse method to

   def parse(self, fn):
        if type(fn) is StringType:
        return self._handler.object()
and added this to the bottom to make the module self testing. I would prefer
it if the name were all lower case as that makes life slightly more robust with win32.
if __name__=='__main__':
                <listen port="9000"/>
        import xmlObjects, StringIO
        fp = StringIO.StringIO(dataset)

        p   = xmlObjects.Parser()
        xml = p.parse(fp)  # where maybe this should be a string or fp

        print xml.getValue("container1.allow.host")     # == 'loki'
        print xml.getValue("container2.allow.host[1]")  # == 'foo.bar.com'
        print xml.getValue("listen[port]", convert=int) # == 9000

        print xml.getValues("container2.allow.host") # == ['loki...', 'foo...' 'baz...']

        print xml.getXML() # does a decent job of reproducing the source
Robin Becker