Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

Creating an XML Document with ASP

Question posted by: emzipoo4u (Newbie) on July 10th, 2008 02:20 PM
Hi, I am creating an XML document with ASP (new to XML). I would like to know how do i add details to a tag e.g. i want to generate <Order xmlns="urn:www.badjda.org/schema/test_order_v3.00.xml"> instead of just <Order>.




Current code i am using at the moment:

<%@LANGUAGE = "VBScript" %>
<%
Response.Buffer = False
'ensure proper headers sent to the client
Response.ContentType = "text/xml"
%>

<%
'these are our variables
Dim objXML , objNews, objPI
'create an instance of the DOM
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
Set objPI = objXML.createProcessingInstruction("xml", "version='1.0'")
'Set objPI2 = objXML.createProcessingInstruction ("xml-stylesheet", "type='text/xsl'", "href='eBIS_MAM.xsl'")
objXML.insertBefore objPI, objXML.childNodes(0)

'Create our root element using the createElement method
Set objXML.documentElement = objXML.createElement("Header")
'Create the newsitem element
Set objNews = objXML.createElement("Manifest")
'now we will create all the child elements in this case
'title , link and description
objNews.appendChild objXML.createElement("document")
objNews.appendChild objXML.createElement("name")
objNews.appendChild objXML.createElement("description")
'now we add values to the child elements
objNews.childNodes(0).text = ""
objNews.childNodes(1).text = ""
objNews.childNodes(2).text = "order"
'add the newsitem element to the news element
objXML.documentElement.appendChild objNews.cloneNode(true)
'write the document using the xml method of the DOM

Response.Write objXML.xml
objXML.save "wwwroot\upload\genertexmlfile.xml"

%>
jkmyoung's Avatar
jkmyoung
Moderator
797 Posts
July 14th, 2008
09:50 PM
#2

Re: Creating an XML Document with ASP
Use the createNode function, eg

createNode(NODE_ELEMENT, Order, "urn:www.badjda.org/schema/test_order_v3.00.xml")

Reply
Reply
Not the answer you were looking for? Post your question . . .
189,891 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top XML Forum Contributors