|
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
%>
|