|
Technical Interview Questions
Visual Basic Interview Question
.NET Web Interview Questions
.NET
Interview Questions
C#
Interview Questions
.........More
Source Codes
Asp .NET Source Codes
Asp VB Script Source Codes
.........More
Soft Skills
Communication Skills
Leadership Skills
.........More
|
|
Asp/VB Script Source Codes
Create XML Files using ASP
In this example we are going to create a simple XML document on the web server .
The srtucture of the document will be as follows .
<P><?xml version="1.0" ?> <BR><news><BR><newsitem><BR><title>programmingsite.co.ukP</title>
<BR><link>http://www.programmingsite.co.uk</link> <BR><description>programming
resources</description> <BR></newsitem><BR></news></P>
<P>Anyway lets go with the code to create this example </P>
<P><%@LANGUAGE = "VBScript" %><BR><%<BR>Response.Buffer =
False<BR>'ensure proper headers sent to the client<BR>Response.ContentType =
"text/xml"<BR>%><BR><?xml version="1.0"?><BR><%<BR>'these are our
variables<BR>Dim objXML , objNews<BR>'create an instance of the DOM<BR>Set
objXML = Server.CreateObject("Microsoft.XMLDOM")<BR>'Create our root element
using the createElement method<BR>Set objXML.documentElement =
objXML.createElement("news")<BR>'Create the newsitem element<BR>Set objNews =
objXML.createElement("newsitem")<BR>'now we will create all the child elements
in this case<BR>'title , link and description<BR>objNews.appendChild
objXML.createElement("title")<BR>objNews.appendChild objXML.createElement("link")<BR>objNews.appendChild
objXML.createElement("description")<BR>'now we add values to the child
elements<BR>objNews.childNodes(0).text = "programmingsite.co.uk"<BR>objNews.childNodes(1).text
= "http://www.programmingsite.co.uk"<BR>objNews.childNodes(2).text =
"programming resources"<BR>'add the newsitem element to the news element<BR>objXML.documentElement.appendChild
objNews.cloneNode(true)<BR>'write the document using the xml method of the
DOM<BR>Response.Write objXML.xml<BR>%> <BR></P>
<<<----- Return to
Asp/VB Script Source
Code Questions Page.
Have a Question ?
post your questions here. It
will be answered as soon as possible.
Check
Microsoft .Net Interview Questions
for more Microsoft
.Net Interview Questions with Answers.
Check
.Net Database Interview
Questions for more .Net Database Interview Questions with answers
Check
Job Interview Questions
for more Interview Questions with Answers
|