#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    101
    Rep Power
    10

    How not to generate <?xml version="1.0" ?> in python


    Hello,
    I building an xml using minidom. Is there a way not generate
    <?xml version="1.0" ?> at the top of my xml-file using python. I save my output to a file and can manually get rid of this line but I wantt python not generate this line, any function I can use for not generate this line. Any help is appreciated.
    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    You can get the first element of the dom and call writexml, toxml or toprettyxml on that. This should do what you want.

    e.g.

    Code:
    dom = xml.dom.minidom.parseString(document)
    print dom.documentElement.toprettyxml()
    Dave - the Developers' Coach

IMN logo majestic logo threadwatch logo seochat tools logo