Write Integer to XML Node in minidom
Question: I'm using minidom in Python to create an XML formatted log file for completed
tasks. Part of the process is to compare the last modified time of a file to
the time that that files data was recorded into the log. I plan on doing that
via:

    
    
    if modTime < recTime:
      do_something()
    

For example, `foo.pdf` was modified at 10:40am, then at 10:46am the log
recorded foo.pdf's modified time. So a portion of the log _should_ look
something like this:

    
    
    <Printed Orders>
      <foo.pdf>
        <Date Recorded>
          1352486780
        </Date Recorded>
      </foo.pdf>
    

However, when I attempt to write the times in their integer formats to the XML
file I get the error:

    
    
    TypeError: node contents must be a string
    

So, my questions are:  
Is there a way to write an integer to an XML file? (Preferrably using minidom
as to not clutter my script with more imports)  
  
If there isn't, is there a better way to compare the modified time I pull from
the file itself and recorded time I pull from the XML file than converting the
recorded time to a string, writing to the XML file, pulling the rec time from
the XML file later on, and then converting that string back to an integer?

Also, in case you're wondering, the plan is to do once-daily purges of a
directory, deleting `foo.pdf` and other files based on the comparison of their
own mod/rec times. If `foo.pdf` hasn't been modified since it was entered into
the log, it will be deleted.

Thanks!


Answer: Just look at the output you expect. How would XML know if that is an integer
or a string. With XML in general, you have to say everything with tags. Thus,
everything is treated as a string.

You do not need to convert the string to a int, unless the other time is an
int, because the time-string will not become any longer than it is now for a
really long time (over 3,000 years). However, I am not sure why you have so
much dislike for doing that conversion. If it's really a big deal, use JSON.

