Valg af enkelt variabel
HejsaJeg er ved at lave en rss-reader (er ny i faget - derfor en lidt rodet kode). Jeg vil gerne have mulighed for at kunne hive fx titlen i feedet ud som en seperat variable. Hvordan gøres dette?
Her er min kode:
-----------------------
Sub MainUpdate()
txtMain.Text = ""
strURL "http://www.f1racing.net/en/xml/rss/en.xml"
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async = False
xmlDoc.Load strURL
For Each x In xmlDoc.documentElement.childNodes
For Each y In x.childNodes
'----------------------
If y.nodeName = "title" Then
txtMain.Text = txtMain.Text & y.Text & vbCrLf '& vbcrlf 'x.nodename & x.nodename & x.text & vbcrlf 'y.item(i-1).getAttribute("code") & ": " & y.item(i-1).getAttribute("desc") & ": " & y.item(i-1).getAttribute("rate") & vbcrlf
txtMain.Text = (txtMain.Text) & vbCrLf '& vbcrlf
'txt.Text = var1 & var2 & var3
txtMain.SelStart = InStr(txtMain.Text, txtMain.Text)
txtMain.SelLength = Len(txtMain.Text)
txtMain.SelBold = True
Else
If y.nodeName = "link" Then
txtMain.Text = txtMain.Text & y.Text & vbCrLf '& vbcrlf 'x.nodename & x.nodename & x.text & vbcrlf 'y.item(i-1).getAttribute("code") & ": " & y.item(i-1).getAttribute("desc") & ": " & y.item(i-1).getAttribute("rate") & vbcrlf
txtMain.Text = txtMain.Text & vbCrLf & "----------------" & vbCrLf
Else
If y.nodeName = "description" Then
txtMain.Text = txtMain.Text & y.Text & vbCrLf '& vbcrlf 'x.nodename & x.nodename & x.text & vbcrlf 'y.item(i-1).getAttribute("code") & ": " & y.item(i-1).getAttribute("desc") & ": " & y.item(i-1).getAttribute("rate") & vbcrlf
txtMain.Text = txtMain.Text & vbCrLf & "----------------" & vbCrLf
End If
End If
End If
'----------------------
For Each z In y.childNodes
If z.nodeName = "title" Then
txtMain.Text = txtMain.Text & z.Text & vbCrLf '& vbcrlf 'x.nodename & x.nodename & x.text & vbcrlf 'y.item(i-1).getAttribute("code") & ": " & y.item(i-1).getAttribute("desc") & ": " & y.item(i-1).getAttribute("rate") & vbcrlf
txtMain.Text = txtMain.Text '& vbcrlf
Else
If z.nodeName = "link" Then
txtMain.Text = txtMain.Text & z.Text & vbCrLf '& vbcrlf 'x.nodename & x.nodename & x.text & vbcrlf 'y.item(i-1).getAttribute("code") & ": " & y.item(i-1).getAttribute("desc") & ": " & y.item(i-1).getAttribute("rate") & vbcrlf
txtMain.Text = txtMain.Text & vbCrLf
Else
If z.nodeName = "description" Then
txtMain.Text = txtMain.Text & z.Text & vbCrLf '& vbcrlf 'x.nodename & x.nodename & x.text & vbcrlf 'y.item(i-1).getAttribute("code") & ": " & y.item(i-1).getAttribute("desc") & ": " & y.item(i-1).getAttribute("rate") & vbcrlf
txtMain.Text = txtMain.Text & vbCrLf & "----------------" & vbCrLf
End If
End If
End If
Next
Next
Next x
End Sub
-------------------
På forhånd stor tak :)
Hygge
