Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > RSS and Atom
RSS and Atom Ask questions, get answers, discuss creating RSS and Atom feeds or programming apps or sites that create or consume RSS/Atom. Please leave any RSS/Atom politics out of this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the RSS and Atom section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 19th, 2007, 12:51 PM
Registered User
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default removeChild help

I have an rss feed from an external server. Reading it with classic asp works fine, but I want to delete certain <item>'s from it. I have been trying for days but can't get it to work.

When I get all the <item>'s with xmlDOM.getElementsByTagName("item"), I want to delete all double titles (<title>), because I need to create a list of unique authors (which are in the title). I use a For each to walk through the original collection of items and use a comma seperated string to hold unique titles. When a <title> alreade is in the string, that <item> must be deleted.

I've been trying and trying, but can't find the solution,.. it sounds like it must be real simple.

I tried this: http://www.devguru.com/Technologies/...moveChild.html
and different combinations,.. it ends up in errors like this Object doesn't support this property or method: 'removeChild'

I use MSXML2.Domdocument.3.0, I tried version 5 and 6, tried Microsoft.XmlDom like in the examples.)

Someone can point me in the right direction?
Old November 19th, 2007, 12:56 PM
Registered User
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

My code (ASP):

Public Sub ReadRSSDistinct(strURL)

    Dim URLToRSS, MaxNumberOfItems, ErrorMessage, RSSItemsCount
    Dim xmlHttp, xmlDOM, RSSXML
    'Dim RSSItems public
    Dim RSSItem
    Dim blnDelete
    Dim i
    Dim child
    Dim strAuthors
    Dim RSSAuthor

    Dim objRoot
    Dim objExNode
    Dim oldChild

    Response.Expires = -1

    ' URL to RSS Feed to display
    URLToRSS = strURL

    ErrorMessage = ""

    ' ================================================

    Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
    xmlHttp.Open "Get", URLToRSS, False
    RSSXML = xmlHttp.ResponseText

    Set xmlDOM = Server.CreateObject("MSXML2.DomDocument.3.0")
    xmlDOM.async = False
    xmlDOM.validateOnParse = False
    xmlDOM.resolveExternals = False

    If Not xmlDOM.LoadXml(RSSXML) Then
        ErrorMessage = "Can not load XML:" & vbCRLF & xmlDOM.parseError.reason & vbCRLF & ErrorMessage
    End If

    Set xmlHttp = Nothing ' clear HTTP object
    Set RSSItems = xmlDOM.getElementsByTagName("item") ' collect all "items" from downloaded RSS

    RSSItemsCount = RSSItems.Length - 1

    ' if not <item>..</item> entries, then try to get <entry>..</entry>
    If RSSItemsCount = -1 Then
        Set RSSItems = xmlDOM.getElementsByTagName("entry") ' collect all "entry" (atom format) from downloaded RSS
        RSSItemsCount = RSSItems.Length - 1
    End If

    If Not RSSItemsCount = -1 Then

        For i = 0 To RSSItemsCount

            Set RSSItem = RSSItems.Item(i)
            blnDelete = False

            For Each child in RSSItem.childNodes

                Select case lcase(child.nodeName)
                    Case "title"
                        RSSAuthor = GetAuthor(child.text)
                        If Len(strAuthors) = 0 Then
                            strAuthors = Trim(RSSAuthor)
                            blnDelete = True
                            If InStr(strAuthors, Trim(RSSAuthor)) = 0 Then
                                strAuthors = strAuthors & "," & Trim(RSSAuthor)
                                blnDelete = False
                                'Response.Write "Delete: " & RSSAuthor & "<br />"
                                blnDelete = True
                            End If
                        End If

                        If blnDelete = True Then

                            If RSSItem Is Nothing Then
                                 Response.Write "Nothing: " & RSSAuthor & "<br />"
                                Dim childitem
                                Dim objRootItem

                                Set objRoot = xmlDOM.getElementsByTagName("item")

                                Set objExNode = objRoot.Item(i)

                            End if
                        End If
                End Select
    End If

    If Len(ErrorMessage) > 0 Then
        Response.Write "<script language='javascript'>alert('" & ErrorMessage & "');</script>"
    End If

    Set xmlDOM = Nothing ' clear XML

End Sub

Similar Threads
Thread Thread Starter Forum Replies Last Post
document.DocumentElement.RemoveChild Error jrbancroft C# 2005 2 August 7th, 2006 10:36 PM
Need help with documentElement.removeChild adsioii XSLT 2 January 16th, 2004 02:12 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.