Avatar billede bb_maze Nybegynder
06. maj 2005 - 00:58 Der er 1 løsning

Valg af enkelt variabel

Hejsa

Jeg 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
Avatar billede bb_maze Nybegynder
20. maj 2005 - 01:04 #1
Lukker...
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester