Announcement

Collapse
No announcement yet.

Populating a pulldown from XML

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Populating a pulldown from XML

    Hello, and thank you in advance

    Does anyone have a VTW script that will allow me to populate a pulldown object?

    I have an xml in which I have information I need transferred to a pulldown in VTW, the issue I am having is that some of the info is repeated, how do I get rid of the repeated info and then populate the pulldown

    Please let me know if I need to add more info to better explain what I need to accomplish


  • #2
    Something like this?
    Code:
      function ReadRSSData()
       
              bLoading = true
              Set XmlDom = CreateObject("Microsoft.XMLDOM")
              XMLDom.async=false
              XMLDom.preserveWhiteSpace = true
       
              theURL = "http://news.bbc.co.uk/rss/newsonline_world_edition/front_page/rss091.xml"
       
              if (Len(Trim(txtRSSURL.UTF8Text)) > 0) then
                      theURL = txtRSSURL.UTF8Text
              else
                      txtRSSURL.UTF8Text = theURL
              end if
       
              loadedOK = XmlDom.load(theURL)
       
              if (loadedOK) then
                      lbHeadlines.clear()
                      set headlineNodeList = XmlDom.selectNodes("/rss/channel/item/title/text()")
                      set summaryNodeList = XmlDom.selectNodes("/rss/channel/item/description/text()")
                      set pubDateNodeList = XmlDom.selectNodes("/rss/channel/item/pubDate/text()")
       
                      for each Node In HeadlineNodeList
                              lbHeadlines.Items.add(Node.Text)
                      next
              else
                      bLoading = false
                      msgbox "No RSS data was retrieved." & chr(13) & chr(13) & "This could be because the URL you have entered is incorrect, or the site is not responding." & chr(13) & chr(13) & "Please check the URL and try again.", vbOkOnly + vbExclamation, "RSS Data could not be found"
              end if
       
              objNodeList = ""
              bLoading = false
       
      end function

    Comment


    • #3
      Lars Henriksen Thanks, I will give this a try

      Comment


      • #4
        Lars Henriksen Again thank you for your help

        my xml is formatted like this, what I need from this xml is the race_name1, the script you send me with some modification is capturing all the nodes inside each Elections, so I get the following

        """"Governor 100 Gavin Newsom Y 1397445 33 DEM Gavin Newsom John Cox Y 1097877 26 GOP John Cox"""

        and I need only the race_name1 text/value in the xml sample below it would be the word Governor, the other issue is the way the xml is formatted some of the races are repeated as you see below the word governor is repeated, how do get rid of the repeats?


        Code:
           <Elections>
              <race_name1>Governor</race_name1>
              <race_name2></race_name2>
              <pct_precincts_reporting>100</pct_precincts_reporting>
              <cand1_first_name>Gavin</cand1_first_name>
              <cand1_last_name>Newsom</cand1_last_name>
              <cand1_winner>Y</cand1_winner>
              <cand1_vote_total>1397445</cand1_vote_total>
              <cand1_pct_total>33</cand1_pct_total>
              <cand1_party_name1>DEM</cand1_party_name1>
              <cand1_pic_id></cand1_pic_id>
              <cand1_full_name>Gavin Newsom</cand1_full_name>
              <cand2_first_name>John</cand2_first_name>
              <cand2_last_name>Cox</cand2_last_name>
              <cand2_winner>Y</cand2_winner>
              <cand2_vote_total>1097877</cand2_vote_total>
              <cand2_pct_total>26</cand2_pct_total>
              <cand2_party_name1>GOP</cand2_party_name1>
              <cand2_pic_id></cand2_pic_id>
              <cand2_full_name>John Cox</cand2_full_name>
           </Elections>
           <Elections>
              <race_name1>Governor</race_name1>
              <race_name2></race_name2>
              <pct_precincts_reporting>100</pct_precincts_reporting>
              <cand1_first_name>Antonio</cand1_first_name>
              <cand1_last_name>Villaraigosa</cand1_last_name>
              <cand1_winner></cand1_winner>
              <cand1_vote_total>559327</cand1_vote_total>
              <cand1_pct_total>13</cand1_pct_total>
              <cand1_party_name1>DEM</cand1_party_name1>
              <cand1_pic_id></cand1_pic_id>
              <cand1_full_name>Antonio Villaraigosa</cand1_full_name>
              <cand2_first_name>Travis</cand2_first_name>
              <cand2_last_name>Allen</cand2_last_name>
              <cand2_winner></cand2_winner>
              <cand2_vote_total>405262</cand2_vote_total>
              <cand2_pct_total>10</cand2_pct_total>
              <cand2_party_name1>GOP</cand2_party_name1>
              <cand2_pic_id></cand2_pic_id>
              <cand2_full_name>Travis Allen</cand2_full_name>
           </Elections>

        Comment


        • #5
          Lars Henriksen Thank you for your help, yesterday I was able to figure out what I was doing wrong, I was trying to add a node to a dictionary instead if the text value of the node, once I changed that everything works ok.

          On your script after you define the function, the first line on that function is

          bLoading = true

          What does this line do? I noticed that you are changing this to false at the end of the script, why?

          from the script how would I access the individual Items on the drop down?

          Again thank you for your help


          Comment


          • #6
            Its a function used to show a panel while it loads. Here is the complete example.
            https://www.dropbox.com/s/h1ycnq2ae1...ample.vtw?dl=0
            If you click a headline in the listbox it will show you the content of each node on the right. Hope this helps

            Comment

            Working...
            X