Object required error while parsing XML

I get the error
Object required: 'item(...)'
What is wrong?

Here is the code:
Response.Buffer = True
Dim objXMLHTTP, xml, xmlFile, xmlLocation, xmlDir, elements, i
xmlFile = "http://some_domain/pride/includes/article_index_4.xml"
NumberOfLinks = 3

Dim objXML
Set objXML = Server.CreateObject("microsoft.XMLDOM")

call objXML.setProperty("ServerHTTPRequest", True)
call objXML.Load(xmlFile)

Set elements = objXML.getElementsByTagName("item")  

For i = 1 to NumberOfLinks
tTitle = elements.item(i).childNodes(0).Text '''''''''''''''''''' The Error Line '''''''''''''''''''''''''''''''

Set objXML = Nothing

The XML Code
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
    <title>My company RSS Feed</title>
    <description>My company extends products using XML</description>
    <pubDate>Fri, 16 Apr 2006 15:15:00 +0200</pubDate>
      <title>New company started</title>
      <description>Here the description goes</description>
      <pubDate>Fri, 16 Feb 2006 00:00:00 +0200</pubDate>
      <title>New company2 started</title>
      <description>Here2 the description goes</description>
      <pubDate>Fri, 16 Feb 2006 00:00:00 +0200</pubDate>
      <title>New company3 started</title>
      <description>Here3 the description goes</description>
      <pubDate>Fri, 16 Feb 2006 00:00:00 +0200</pubDate>
Who is Participating?
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
You may want to check that it is loading the XML ok. I tried it from a file and it worked ok.
here's something that may help.

Function RSSReader(url, numItems, showAll)
      URLToRSS = url
      MaxNumberOfItems = numItems
      MainTemplateHeader = "<table width='100%' cellpadding='0' cellspacing='0'>"
      MainTemplateFooter = "</table>"
      ItemTemplate = "<tr><td style='border-bottom:1px solid #EEE;'><a href=" & """{LINK}""" & " target='_blank'>{TITLE}</a>{DESCRIPTION}{pubDate}{Author}</td></tr>"
      ErrorMessage = "Error has occured while trying to process " &URLToRSS & "<BR>Please contact web-master"
      Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP.3.0")
            xmlHttp.Open "Get", URLToRSS, false
            RSSXML = xmlHttp.ResponseText
            Set xmlDOM = Server.CreateObject("MSXML2.DomDocument.3.0")
                  xmlDOM.async = false
            Set xmlHttp = Nothing ' clear HTTP object
            Set RSSItems = xmlDOM.getElementsByTagName("item") ' collect all "items" from downloaded RSS
      Set xmlDOM = Nothing ' clear XML
      RSSItemsCount = RSSItems.Length-1
      ' writing Header
      if RSSItemsCount > 0 then
            Response.Write MainTemplateHeader
      End If
      j = -1
      For i = 0 To RSSItemsCount
            Set RSSItem = RSSItems.Item(i)
            for each child in RSSItem.childNodes
                  Select case lcase(child.nodeName)
                        case "title"
                              RSStitle = child.text
                        case "link"
                              RSSlink = child.text
                        case "description"
                              RSSdescription = child.text
                        case "pubdate"
                              RSSPubDate = child.text
                        case "author"
                              RSSAuthor = child.text
                  End Select
            j = J+1
            if J < MaxNumberOfItems then
                  ItemContent = Replace(ItemTemplate,"{LINK}",RSSlink)
                  if showAll then
                        ItemContent = Replace(ItemContent,"{TITLE}","<div style='padding-left:10px;font-weight:bold;'>"&RSSTitle&"</div>")
                        ItemContent = Replace(ItemContent,"{pubDate}","<div style='font-size:85%;font-weight:bold;font-style:italic;text-align:right;'>Published: "&RSSPubDate&"</div>")
                        ItemContent = Replace(ItemContent,"{Author}","<div style='font-size:85%;font-weight:bold;font-style:italic;text-align:right;'>"&RSSAuthor&"<div align='right' style='padding-right:10px;'><a href='javascript:window.scrollTo(0,0);'><img src='/storage/images/16x_top.gif' alt='Return To The Top Of The Page' border='0' /></a></div></div>")
                        ItemContent = Replace(ItemContent,"{DESCRIPTION}","<div style='font-size:85%;padding:0 10px 0 25px;'>"&RSSDescription&"</div>")
                        ItemContent = Replace(ItemContent,"{TITLE}","<div style='padding-left:10px;'>"&RSSTitle&"</div>")
                        ItemContent = Replace(ItemContent,"{pubDate}","")
                        ItemContent = Replace(ItemContent,"{Author}","")
                        ItemContent = Replace(ItemContent,"{DESCRIPTION}","")
                  end if
                  ItemContent = ""
            End if
      ' writing Footer
      if RSSItemsCount > 0 then
            Response.Write MainTemplateFooter
            Response.Write ErrorMessage
      End If
End Function

to use it simply:
<%Call RSSReader("http://hosted.ap.org/lineups/WORLDHEADS-rss_2.0.xml?SITE=RANDOM&SECTION=HOME", 5, False)%>

5 is the number of articles I want to display
False will display the titles only (change it to true for the whole article)
Carl TawnSystems and Integration DeveloperCommented:
The collection of nodes is zero based, so your code should read:

    For i = 0 to NumberOfLinks - 1
       tTitle = elements.item(i).childNodes(0).Text '''''''''''''''''''' The Error Line '''''''''''''''''''''''''''''''
quest_capitalAuthor Commented:
same error
have you tried my method?

and I believe they are child.nodeName
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.