Add Doctype to XML document

I am creating an xml document like this:

Set XMLdoc = Server.CreateObject("MSXML2.DOMDOCUMENT.4.0")
XMLdoc.insertBefore ...
XMLdoc.appendChild ...

I want to add Doctype to this xml document. How do I do that? Looks like I cannot use XMLdoc.CreateProcessingInstruction to add Doctype.
dj_user2Asked:
Who is Participating?
 
Om PrakashConnect With a Mentor Commented:
Please check the example:

http://bytes.com/topic/asp-classic/answers/125616-doctype
Set XmlDocument1 = Server.CreateObject("Msxml2.DOMDocument.3.0")
XmlSource = "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf & _
"<!DOCTYPE FREIGHT SYSTEM ""test2004123001.dtd"">" &
vbCrLf & _
"<FREIGHT />"
XmlDocument1.validateOnParse = False
XmlDocument1.loadXML(XmlSource)

Open in new window

0
 
sybeCommented:
>  Looks like I cannot use XMLdoc.CreateProcessingInstruction to add Doctype.

Why not?

<%
sCharSet  = "UTF-8"
Set oInstruction = oXML.createProcessingInstruction("xml", "version=""1.0"" encoding=""" & sCharSet & """")
oXML.insertBefore oInstruction, oXML.childNodes.item(0)
%>
0
 
dj_user2Author Commented:
None
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.