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 May 17th, 2005, 10:02 PM
Registered User
 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to hsascubaboy Send a message via MSN to hsascubaboy
Default code for rss work

Hi,
I'm new to programming in vb6 and i am trying to download, parse and save an RSS(XML) file. I am using the wrox XML and VB6 book and it has been a big help so far. I've written most of the code and it works except for 1 thing; I don't get any data from the child nodes, the only data I get is from the parent node.Here is the code:

Private Sub Form_Load()
    getFile

End Sub
Public Sub getFile()

    Dim objDom As MSXML2.DOMDocument
    Set objDom = New MSXML2.DOMDocument
    objDom.async = False
    objDom.Load "http://www.nytimes.com/services/xml/rss/nyt/International.xml"
    objDom.save "c:/test4.xml"
    Dim objElement As IXMLDOMElement
    Dim objNodeList As IXMLDOMNodeList
    Dim sTemp As String
    Dim nIdx As Integer
    Dim sXML As String
    Dim fsoSave As Scripting.FileSystemObject
    Dim tSave As Scripting.TextStream


    With objDom

        sTemp = ""
        Set objElement = .getElementsByTagName("description").Item(0)
        For nIdx = 0 To objElement.childNodes.length - 1
            sTemp = sTemp & objElement.childNodes.Item(nIdx).nodeValue
        Next
        txtdescription = sTemp

        sTemp = ""
        Set objElement = .getElementsByTagName("title").Item(0)
        For nIdx = 0 To objElement.childNodes.length - 1
            sTemp = sTemp & objElement.childNodes.Item(nIdx).nodeValue
        Next
        txttitle = sTemp

    End With 'objDom

    sXML = ""
    sXML = "<np title=|The New York Times|>" & vbCrLf
    sXML = sXML & "<s name=|" & txttitle & "|>" & vbCrLf
    sXML = sXML & "<a hl=|" & txtdescription & "|" & vbCrLf

    Set fsoSave = New FileSystemObject
    Set tSave = fsoSave.OpenTextFile("c:/final.txt", ForWriting, True)
    tSave.Write (sXML)
    tSave.Close

End Sub

This is everything so far. I think the problem is in the With statement. Any help would be appreciated.

thanx
JV

 
Old May 28th, 2005, 11:41 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Can you show a portion of the source XML? It's not a very elegant way of creating XML, writing text to a file, why not use the built in methods or XSLT?

--

Joe (Microsoft MVP - XML)
 
Old May 29th, 2005, 06:51 PM
Registered User
 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to hsascubaboy Send a message via MSN to hsascubaboy
Default

Joe,
I did some more reading and found XSLT was the way to go. Thanx for the reply.

John





Similar Threads
Thread Thread Starter Forum Replies Last Post
RSS Code for python 2.5 (pyxml Vs 4Suite) dsampson BOOK: Beginning XML, 4th Ed ISBN: 978-0-470-11487-2 1 February 12th, 2008 10:49 AM
Browser RSS feed auto detection code here madok BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 29th, 2006 09:04 AM
code clinic - Why wont example asp code work? jardbf Classic ASP Basics 3 April 27th, 2006 06:22 PM
code does not work keithschm Beginning PHP 5 January 10th, 2005 09:52 AM





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