Using file objects with elementtree

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dj

    Using file objects with elementtree

    Hello,

    Rather then holding my XML document in memory before writing it to
    disk, I want to create a file object that elementtree will write each
    element to has it is created. Does any one know how to do that ?

    Here is my code so, far:

    fd = open("page.xml" , "w")
    tree.write( fd, encoding="iso-8859-1")

    I know there's something I am doing wrong, but I just do not know
    what.
  • castironpi@gmail.com

    #2
    Re: Using file objects with elementtree

    On May 14, 3:09 pm, dj <d.a.aberna...@ gmail.comwrote:
    Hello,
    >
    Rather then holding my XML document in memory before writing it to
    disk, I want to create a file object that elementtree will write each
    element to has it is created. Does any one know how to do that ?
    >
    Here is my code so, far:
    >
    fd = open("page.xml" , "w")
    tree.write( fd, encoding="iso-8859-1")
    >
    I know there's something I am doing wrong, but I just do not know
    what.
    Sure. Relational databases are more widely useful. They're the
    binary hold-on-disk for you-- a big XML file.

    Comment

    • Diez B. Roggisch

      #3
      Re: Using file objects with elementtree

      dj schrieb:
      Hello,
      >
      Rather then holding my XML document in memory before writing it to
      disk, I want to create a file object that elementtree will write each
      element to has it is created. Does any one know how to do that ?
      >
      Here is my code so, far:
      >
      fd = open("page.xml" , "w")
      tree.write( fd, encoding="iso-8859-1")
      >
      I know there's something I am doing wrong, but I just do not know
      what.
      This isn't possible. How should ET handle the case that you add a
      child-node to a node that has been rendered already?

      What you could try is to serialize subtrees that are closed to a stream.


      Diez

      Comment

      • castironpi@gmail.com

        #4
        Re: Using file objects with elementtree

        On May 14, 5:41 pm, "Diez B. Roggisch" <de...@nospam.w eb.dewrote:
        dj schrieb:
        >
        Hello,
        >
        Rather then holding my XML document in memory before writing it to
        disk, I want to create a file object that elementtree will write each
        element to has it is created. Does any one know how to do that ?
        >
        Here is my code so, far:
        >
        fd = open("page.xml" , "w")
        tree.write( fd, encoding="iso-8859-1")
        >
        I know there's something I am doing wrong, but I just do not know
        what.
        >
        This isn't possible. How should ET handle the case that you add a
        child-node to a node that has been rendered already?
        >
        What you could try is to serialize subtrees that are closed to a stream.
        >
        Diez
        What do we render?

        Comment

        • Stefan Behnel

          #5
          Re: Using file objects with elementtree

          castironpi@gmai l.com wrote:
          What do we render?
          Sur.

          Stefan

          Comment

          • castironpi

            #6
            Re: Using file objects with elementtree

            On May 15, 1:14 pm, Stefan Behnel <stefan...@behn el.dewrote:
            castiro...@gmai l.com wrote:
            What do we render?
            >
            Sur.
            >
            Stefan
            I'm pretty sure 'inputs' come from the real world. I guess the fear
            would be my hands aren't happy. Concerns include age fitity, a
            propriety, and making up words. Blah?

            Comment

            • Stefan Behnel

              #7
              Re: Using file objects with elementtree

              castironpi wrote:
              [...], and making up words. Blah?
              "Blah" is not made up. Try again.

              Stefan

              PS: this might be getting slightly off-topic...

              Comment

              Working...