I'm trying to read an XML file using ASP (and I'm using the example from here:
http://www.15seconds.com/issue/990527.htm ) but I keep getting 0 items returned. I'm doing a Response.Write(noOfHeadlin
es) and getting zero. Does anyone have any ideas?
Here's my code...
<html>
<head>
<title>Read XML Test</title>
</head>
<body>
<%
Set objXML = Server.CreateObject("Micro
soft.XMLDO
M")
Set objLst = Server.CreateObject("Micro
soft.XMLDO
M")
Set objHdl = Server.CreateObject("Micro
soft.XMLDO
M")
objXML.async = False
objXML.Load (Server.MapPath("mostRecen
tScripting
News.xml")
)
' If objXML.parseError.errorCod
e <> 0 Then
' handle the error
' End If
Set objLst = objXML.getElementsByTagNam
e("item")
noOfHeadlines = objLst.length
%>
<HTML><BODY>
<H1>Scripting News Headlines</H1>
<%
Response.Write(noOfHeadlin
es)
For i = 0 To (noOfHeadlines - 1)
Set objHdl = objLst.item(i)
Response.Write("<a href=""" & _
objHdl.childNodes(1).child
Nodes(0).t
ext & _
""">" & objHdl.childNodes(0).text & _
"</a><br>")
Next
%>
</body>
</html>
And here's the XML file...
<?xml version="1.0"?>
<!DOCTYPE scriptingNews SYSTEM
"
http://www.scripting.com/dtd/scriptingNews.dtd">
<scriptingNews>
<header>
<copyright>Copyright 1997-1999 UserLand Software, Inc.
</copyright>
<scriptingNewsVersion>1.0<
/scripting
NewsVersio
n>
<pubDate>Wed, 03 Mar 1999 08:00:00 GMT</pubDate>
<lastBuildDate>Thu, 04 Mar 1999 03:37:03 GMT</lastBuildDate>
</header>
<item>
<text>Wired: A Linux Car Stereo! Wow.</text>
<link>
<url>
http://www.wired.com/news/news/technology/
story/18236.html
</url>
<linetext>A Linux Car Stereo</linetext>
</link>
</item>
<item>
<text>According to News.com, Hewlett-Packard will offer
customers storage and computing on a rental basis.
</text>
<link>
<url>
http://www.news.com/News/Item/
0,4,33202,00.html?st.ne.fd
.mdh
</url>
<linetext>According to News.com</linetext>
</link>
</item>
</scriptingNews>
Thanks,
MastaLlama
Start Free Trial