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

Display XML files using ASP

First start your text editor and enter the following , this will be your XML file .
<P>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;<BR>&lt;
news&gt;<BR>&lt;item&gt;<BR>&lt;title&gt;new domain name&lt;/title&gt;<BR>&lt;link&gt;
http: //www. techpreparation.com&lt;/link&gt;<BR>&lt;description&gt; programming tutorials and code&lt;/description&gt;<BR>&lt;/item&gt;<BR>
&lt;/news&gt;</P>
<P>Save this as demo.xml for the purpose of this example . </P>
<P>Now we will look at the ASP page to retrieve these values , we want the title , link and the description .</P>
<P>&lt;%<BR>
Dim objXML<BR>'create an instance of the MSXML parser<BR>
Set objXML = Server.CreateObject("microsoft.XMLDOM")<BR>
'load up or XML file , this is stored in the same directory as the script<BR>'in this example<BR>
objXML.Load (Server.MapPath("demo.xml"))
<BR>'if there are no errors<BR>If objXML.parseError.errorcode = 0 Then<BR>'strTitle is the value of the child node of the &lt;item&gt; element<BR>
strTitle = objXML.documentElement.firstChild.firstChild.text<BR>
'use the nodeList object , to get the link and description as strings . The index is <BR>'zero based so &lt;link&gt; = 1 and description = 2.<BR>
strLink = objXML.documentElement.firstChild.childNodes(1).Text<BR>strDescription = objXML.documentElement.firstChild.childNodes(2).Text<BR>'print out our title<BR>response. Write (strTitle &amp; "&lt;br&gt;")<BR>'print out the URL<BR>Response.Write (strLink &amp; "&lt;br&gt;")<BR>'print the description<BR> Response.Write (strDescription &amp; "&lt;br&gt;")<BR>'if there are errors then we print a message <BR> Else<BR> Response.Write ("There was an error")<BR>End If <BR>'clean up our resources<BR> Set objXML = Nothing<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