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

    Join Date
    Apr 2004
    Posts
    101
    Rep Power
    11

    Adding DOCTYPE in the xml output file!


    Hi,
    Can anyone help me how to add the DOCTYPE in the xml output file. I am build an xml through the program but I need to add
    <!DOCTYPE Test SYSTEM 'Test.dtd'>

    at the top of the xml file. My xml file looks like:

    <?xml version="1.0" ?>
    <Test>
    .... more elements here
    </Test>

    now I also want to add
    <!DOCTYPE Test SYSTEM 'Test.dtd'>
    after <?xml version="1.0" ?>
    how can I do this in the code.

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13
    Where is the XML output coming from?
    Debian - because life's too short for worrying.
    Best. (Python.) IRC bot. ever.
  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Assuming you have the XML stored in a string, just split th string at the end of the first line and use list.index() to slot the DOCTYPE in between.

    Code:
    ...
    doctype = '<!DOCTYPE Test SYSTEM \'Test.dtd\'>'
    XML.split('\n', 1)
    XML.index(doctype, 1)
    ...
    Or thats the basic idea . There there are plenty of other ways you could do this.

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo