def XMLtoFileObject(self, fname, tree=None):

        """
        Gets as arguments a filename and a tree then writes the tree to a file with
        the given filename.Returns true if everything has been accomplished
        correctly.A IO error is also raised in the bad case.

        """

        try :
            import os.path
            xmlworktree = tree
            if os.path.exists(fname):
                xmlobj = file(fname,mode='ab+')
            else:
                xmlobj = file(fname,mode='wb+')
            xmlobj.write(xmlworktree)
            xmlobj.close()
            return True
        except ImportError:
            raise ImportError, "os.path missing or behaving uncorrectly.Review your \
        Python's version notes"

        Gets as arguments a filename and a tree then writes the tree to a file with
        the given filename.Returns true if everything has been accomplished
        correctly.A IO error is also raised in the bad case.

        
recipes/Python/498101_Simpliest_XML_generator/recipe-498101.py