programmingsite : code , tutorials and scripts
Navigation

home


ASP
ASP.net
C
C++
C#
PHP
Java
JavaScript
Powershell
VB.net

Visual Basic


Resources
code
tutorials
training

Ads
Products

 

 

Display an XML file




Display an XML file
First start your text editor and enter the following , this will be your XML file .

<?xml version="1.0" encoding="ISO-8859-1"?>
<news>
<item>
<title>new domain name</title>
<link>http://tutorials.programmingsite.co.ukk</link>
<description>programming tutorials and code</description>
</item>
</news>

Save this as demo.xml for the purpose of this example .



Now we will look at the ASP page to retrieve these values , we want the title , link and the description .

<%
Dim objXML
'create an instance of the MSXML parser
Set objXML = Server.CreateObject("microsoft.XMLDOM")
'load up or XML file , this is stored in the same directory as the script
'in this example
objXML.Load (Server.MapPath("demo.xml"))
'if there are no errors
If objXML.parseError.errorcode = 0 Then
'strTitle is the value of the child node of the <item> element
strTitle = objXML.documentElement.firstChild.firstChild.text
'use the nodeList object , to get the link and description as strings . The index is
'zero based so <link> = 1 and description = 2.
strLink = objXML.documentElement.firstChild.childNodes(1).Text
strDescription = objXML.documentElement.firstChild.childNodes(2).Text
'print out our title
response.Write (strTitle & "<br>")
'print out the URL
Response.Write (strLink & "<br>")
'print the description
Response.Write (strDescription & "<br>")
'if there are errors then we print a message
Else
Response.Write ("There was an error")
End If
'clean up our resources
Set objXML = Nothing
%>





Products
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals
Asp Studio 2005
Xtra PHP
Online PHP Script Encoder
Comparison

Links
Make money selling software
Uk shopping
UK price comparison
US price comparison
free articles
free stuff
Gambling resources
Software directory
XBox cheats and more
Sexy free wallpapers
Hosting resources
Nintendo Wii info
Beginners PHP
Health and fitness
Domain names
Dating site
Nintendo DS resources
Dropshippers
Maxi directory
Perfume and fragrances
PC shopping, tips and info
Magazine superstore

Ads