|
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
Display XML files using ASP
First start your text editor and enter the following , this will be your XML
file .
<P><?xml version="1.0" encoding="ISO-8859-1"?><BR><
news><BR><item><BR><title>new
domain name</title><BR><link>
http: //www. techpreparation.com</link><BR><description> programming
tutorials and code</description><BR></item><BR>
</news></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><%<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 <item> 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 <link>
= 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 & "<br>")<BR>'print out the URL<BR>Response.Write (strLink
& "<br>")<BR>'print the description<BR> Response.Write (strDescription
& "<br>")<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>%> <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
|