Announcement

Collapse

Posting messages removed from non registered users

Due to the vast amount of spam the last few months we have as of today removed the ability to post messages from users that are not fully registered.

We do apologize if this causes troubles for some of you but access will be give when the registration is fully completed.

Best Regards
The Moderators
See more
See less

parsing XML in template Wizard

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

  • parsing XML in template Wizard

    Hi Guys,

    I am trying to figure out how to parse an xml from Viz One. The information i need is in the Picfilename when i choose the clip in Template Wizard. I just need a script to parse it.

    The bold type is the information i need:
    <?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom"><id>urn:vme:scripps-central:asset:2101607280002512321</id><title type="text">TRAFFIC ALERT INTERSTITIAL.mov</title><updated>2016-08-04T18:02:15Z</updated><author><name>SYSTEM+admin</name></author>

    Thanks in advance for the help.
    Shotski

  • #2
    This is example for reading xml in pilot.

    Code:
    Dim XMLName, XMLTemp
    Dim timervalue
    timervalue = 50
    updatevalue = 50
    
    Sub LoadXml()
    
    Set XMLName = CreateObject("Microsoft.XMLDOM")
    Set XMLTemp = CreateObject("Microsoft.XMLDOM")
    
    if XMLName.Load("I:\weather\locations.xml") And XMLTemp.Load("I:\weather\day.xml") then
    TWUniLabel7.caption=""
    TWUniButton2.Enabled = true
    call LoadData()
    else
    TWUniLabel7.caption="Xml couldn't load from server. Try backup."
    TWUniButton2.Enabled = false
    end if
    End sub
    
    
    Sub LoadData()
    call GetValue1("101880252")
    call GetValue1("101816670")
    call GetValue1("101609350")
    call GetValue1("101819729")
    call GetValue1("101642911")
    call GetValue1("101735161")
    call GetValue1("101701668")
    call GetValue1("101853909")
    call GetValue1("101871859")
    call GetValue1("101835848")
    call GetValue1("102147714")
    call GetValue1("101668341")
    call GetValue1("101850147")
    
    Set XMLName = Nothing
    Set XMLTemp = Nothing
    
    End Sub
    
    
    
    
    Sub GetValue1(CityId)
    Dim Name,Value
    
    Set Name = XMLName.documentElement
    Set Value = XMLTemp.documentElement
    
    Set NameNodes = Name.selectNodes("//loc[@id="&CityId&"]")
    if NameNodes.length > 0 then
    for Each NameNode In NameNodes
    name = NameNode.Attributes.getNamedItem("name").Text
    TWUniListBox1.Items.Add(name)
    Next
    
    Set ValueNodes = Value.selectNodes("//loc[@id="&CityId&"]/step[0]")
    for Each ValueNode In ValueNodes
    icontext = ValueNode.Attributes.getNamedItem("s").Text
    TWUniListBox3.Items.Add(icontext)
    
    temp1 = ValueNode.Attributes.getNamedItem("tx").Text
    temp2 = ValueNode.Attributes.getNamedItem("tn").Text
    
    templast = Round((Int(temp1) + Int(temp2))/2)
    TWUniListBox2.Items.Add(templast)
    Next
    else
    TWUniLabel7.caption="There is problem about xml."
    TWUniButton2.Enabled = false
    End if
    End sub

    Comment


    • #3
      You can edit it your self. Pilot use Xpath for reading xml tag.
      Maybe This link helps you.

      https://www.w3schools.com/xml/xpath_examples.asp

      Comment


      • #4
        Thanks. Is there a way to Trim text in a text box in Template wizard? Basically i am trying to Trim the text to get rid of some extra characters.

        Comment


        • #5
          what are you trying to trim? if it is empty spaces then the command could be:
          twedit1.text = trim(twedit1.text)

          Comment


          • #6
            Im trying to trim anything after the bold text. The bold text is always a different length though.
            TRAFFIC ALERT INTERSTITIAL.mov</title><updated>2016-08-04T18:02:15Z</updated><author><name>SYSTEM+admin</name></author>

            So basically i just want this: TRAFFIC ALERT INTERSTITIAL.mov

            Comment


            • #7
              The other thing i am trying to do is feed this XML into a dropdown in Template Wizard:
              <?xml version="1.0" encoding="UTF-8"?>
              <items>
              <item>
              <a>XML Item 1a</a>
              <b>XML Item 1b</b>
              </item>
              <item>
              <a>XML Item 2a</a>
              <b>XML Item 2b</b>
              </item>
              <item>
              <a>XML Item 3a</a>
              <b>XML Item 3b</b>
              </item>
              <item>
              <a>XML Item 4a</a>
              <b>XML Item 4b</b>
              </item>
              <item>
              <a>XML Item 5a</a>
              <b>XML Item 5b</b>
              </item>
              </items>

              Comment


              • #8
                In the world of scripting there is alot of way on how to trim that, But based on the sentence in question that you posted there the first thing that came to mind (considering that the BOLD sentence could be of any length) . You could create an array and split the String by the character '<' . If you pulled the text as lines, the bold text is the first set of elements on a new line before the xml code. So split the string by lines "vbLf" . now you have the second line data and if you split that by the '<' and then you just take the first element of that new array which would be the bold text. As for the XML to dropdown, you will use xPath to acess all elements For Each item in items/item/a and items/item/b create an array and push the array elements to the dropdown.items field.

                Comment


                • #9
                  Do you have any examples i could use? I found a script in the forum but having a few issues. The XML info is below. I need the Name to go to one dropdown and the twitter, facebook & email info to change when an option in another dropdown is chosen. For example, Name, then if i choose Twitter, the Twitter handle populates, else if i choose facebook the Facebook handle populates. I'm not great at scripting so any help would be greatly appreciated.

                  Shotski

                  --------------------XML FEED------------------------
                  <?xml version="1.0" encoding="UTF-8"?>
                  <items>
                  <item>
                  <a>FirstName LastName1</a>
                  <b>@Facebook_FirstName_LastName1</b>
                  <c>@Twitter_FirstName_LastName1</c>
                  <d>@Email_FirstName_LastName1</d>
                  </item>
                  <item>
                  <a>FirstName LastName2</a>
                  <b>@Facebook_FirstName_LastName2</b>
                  <c>@Twitter_FirstName_LastName2</c>
                  <d>@Email_FirstName_LastName2</d>
                  </item>
                  <item>
                  <a>FirstName LastName3</a>
                  <b>@Facebook_FirstName_LastName3</b>
                  <c>@Twitter_FirstName_LastName3</c>
                  <d>@Email_FirstName_LastName3</d>
                  </item>
                  <item>
                  <a>FirstName LastName4</a>
                  <b>@Facebook_FirstName_LastName4</b>
                  <c>@Twitter_FirstName_LastName4</c>
                  <d>@Email_FirstName_LastName4</d>
                  </item>
                  <item>
                  <a>FirstName LastName5</a>
                  <b>@Facebook_FirstName_LastName5</b>
                  <c>@Twitter_FirstName_LastName5</c>
                  <d>@Email_FirstName_LastName5</d>
                  </item>
                  </items>

                  --------------SCRIPT-----------------
                  'sub InitForm
                  ' GetXmlClick(Sender)
                  'end sub

                  dim Table(100)

                  Sub GetXmlClick(Sender)
                  dim XmlDom, TalentName, Content1, Content2, Content3, URL
                  'setup
                  Set XmlDom = CreateObject("Microsoft.XMLDOM") 'create xml connection
                  XMLDom.async=false

                  URL="C:\vizrt\DataIntegration\Import_Talent.xml" 'xml to use

                  XmlDom.load(URL)
                  dim i
                  i = 1
                  j = 1
                  k = 1

                  set TalentName = XmlDom.selectNodes("items/item/a") 'get all title nodes
                  set Content1 = XmlDom.selectNodes("items/item/b") 'get all content nodes
                  set Content2 = XmlDom.selectNodes("items/item/c") 'get all content nodes
                  set Content3 = XmlDom.selectNodes("items/item/d") 'get all content nodes

                  TTDrop.Items.Add = "Choose Talent..."
                  TTDrop.ItemIndex = 0
                  SocialDrop.ItemIndex = 0

                  for each x in TalentName 'go through list of titles
                  Listbox1.items.add x.text 'add title text to listbox
                  TTDrop.Items.Add = x.text
                  next

                  for each x in Content1 'go through list of content
                  Table(i) = x.text 'add title text to array
                  i=i+1
                  next

                  for each x in Content2 'go through list of content
                  Table(j) = x.text 'add title text to array
                  j=j+1
                  next

                  for each x in Content3 'go through list of content
                  Table(k) = x.text 'add title text to array
                  k=k+1
                  next

                  End sub

                  Sub ClearListClick(Sender)
                  Listbox1.items.clear 'clear the listbox for data
                  TTDrop.Items.Clear()
                  End sub

                  Sub ListBox1Click(Sender)
                  if SocialDrop.ItemIndex = 0 then
                  Story.text = Table(TTDrop.itemindex(i))

                  elseif SocialDrop.ItemIndex = 1 then
                  Story.text = Table(TTDrop.itemindex(j))

                  elseif SocialDrop.ItemIndex = 2 then
                  Story.text = Table(TTDrop.itemindex(k))

                  'Story.text = Table(TTDrop.itemindex)

                  end if
                  End sub

                  Comment


                  • #10
                    Hi,
                    This link can help you for spliting text. You can use string and array functions.

                    https://www.w3schools.com/asp/asp_re...ions.asp#array

                    Split finction is suitable for this problem in array fumction. But i think xml reading is healthy way

                    Comment


                    • #11
                      Hi There,

                      From your explanation i took your Template and created the following logic..... First of all, You dont really need the Get Xml button since the template automatically loads the xml when its opened, i left it there because maybe updates happen often then you can hit the Get Xml button to load the latest values...

                      This template reads the xml you gave as an example... Then it has 2 dropdowns... The candidate names are in the first one, You select the candidate name you want...
                      2- Then you have a second dropdown that allows you to select( Facebook or Twitter or Email).. There is a textbox below that , which will show the Facebook/Twitter/Email info of the selected account depending on the dropdown you selected.

                      Let me know if this worked for you and is the way you wanted it to be, i rebuilt the code to be more straight forward and make sense using Lists.

                      My template is currently pointing to URL="C:\feed\Import_Talent.xml"
                      you would want to change that to the location where your file is sitting. LINE 52

                      I saved the Template Wizard Template as a file.....
                      You can find the file here --Open your template wizard, and select "Import From File" and import this file to test
                      https://www.mediafire.com/folder/xx8...y1nq/ForumHelp


                      Last edited by Novacane89; 09-18-2017, 11:04 AM.

                      Comment


                      • #12
                        Thanks for all the help guys. I now have a few options to try out!!!! Thanks so much!!!!

                        Comment

                        Working...
                        X