[Zope] converting from XMLdocument to parsedXML

ed colmar ecolmar@qwest.net
Thu, 24 May 2001 09:07:24 -0600


Hey Friends!

    I'm in the process of converting to parsedXML, and after browsing the
zope-xml archives, I'm still stumped...  Maybe it's too early in the morning
to think about this...  =)

   Can anyone that's using the parsedXML product, offer me a few hints?  I
don't think I'm too far off.

   Here's what I'm trying to achieve:

def update(self, client_url):
        """
        Fetch the content from a remote url and rebuild
        the client.
        """
        import urllib                                 # URL tools
        from Products.ParsedXML import ParsedXML, Printer, ExtraDOM, DOM
        import DateTime                               # date calculations

        globalURL=client_url
        # retreive XML file
        resourceURL=globalURL + "localResources.xml"
        f=urllib.urlopen(resourceURL)

        # parse RSS file to DOM using parsedXML
        d=ParsedXML.parseXML(f)

        # get node attributes
        c=d.getElementsByTagName('StarRaveData')[0]
        self.link=c.text_content('localSRSiteURL')
        srversion=c.text_content('CurrentSRVersion')

        # get djs
        djlist=d.getElementsByTagName('StarRaveDJ')

        for StarRaveDJ in djlist:
                # get information about the item
                djid=StarRaveDJ.text_content('SRDJID')
                djname=StarRaveDJ.text_content('SRDJName')
                city=StarRaveDJ.text_content('SRDJCity')
                state=StarRaveDJ.text_content('SRDJState')
                country=StarRaveDJ.text_content('SRDJCountry')

                # add the DJ
                self.addDj(djid, djname, city, state, country)

        return 1