Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add DOCTYPE in the xml output file

Status
Not open for further replies.

abc73

Programmer
Apr 28, 2004
89
US
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
 
I'm sure there is a better way, though I have not ran into this situation yet...

You could always open the file and append the text to the beginning of it, after you export it...

Code:
Open MyXMLFile For Input As #1
  FileText = Input(LOF(1),#1)
Close
FileText = Replace(FileText, "<?xml version=""1.0"" ?>","<?xml version=""1.0"" ?><!DOCTYPE Test SYSTEM 'Test.dtd'>")
Open MyXMLFile For Input As #1
  Print #1, FileText
Close

This may not be the best method in the end, be it should work good enough until you find a better way.

if you want it to be on the second line by itself, just add a VbCrLf in between them...
Code:
FileText = Replace(FileText, "<?xml version=""1.0"" ?>","<?xml version=""1.0"" ?>[b]" & VbCrLf & "[/b]<!DOCTYPE Test SYSTEM 'Test.dtd'>")

Good Luck,
Josh

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Oops, sorry, I thought I was in the VB forum... [neutral]

Sorry about that...[sadeyes]

Good Luck,
Josh ;-)

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top