techpreparation-homepage

Home  Interview Questions  Aptitude Questions  Tutorials  Placement Papers  Search  Resume Guide  Soft Skills  Video  Forum  Blog


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

Subscribe to our Newsletters
Name:
Email:

 

 

  

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>&lt;?xml version="1.0" ?&gt; <BR>&lt;news&gt;<BR>&lt;newsitem&gt;<BR>&lt;title&gt;programmingsite.co.ukP&lt;/title&gt; <BR>&lt;link&gt;http://www.programmingsite.co.uk&lt;/link&gt; <BR>&lt;description&gt;programming resources&lt;/description&gt; <BR>&lt;/newsitem&gt;<BR>&lt;/news&gt;</P>
<P>Anyway lets go with the code to create this example </P>
<P>&lt;%@LANGUAGE = "VBScript" %&gt;<BR>&lt;%<BR>Response.Buffer = False<BR>'ensure proper headers sent to the client<BR>Response.ContentType = "text/xml"<BR>%&gt;<BR>&lt;?xml version="1.0"?&gt;<BR>&lt;%<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>%&gt; <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