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
|