Announcement

Collapse
No announcement yet.

Parsing or Sorting in Template Wizard

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

  • Parsing or Sorting in Template Wizard

    Below is a XML of sports scores & schedules. It changes from day to day depending on what is going on and the leagues can be in different places of the XML. The issue i am running into is how to only populate the league i want with a dropdown. For example, if i choose MLB in the dropdown only the MLB scores or schedules are populated to the text fields and not anything else. This needs to work in Template Wizard. I have also attached a photo of the actual XML since it wont copy with the embedded nodes. XML view.PNG

    Any help is greatly appreciated,
    Shotski


    <root>
    <DATA>
    <Sports>
    <game_id>WNBA-2131243</game_id>
    <league_name1>WNBA</league_name1>
    <forced_visit_team>Minnesota</forced_visit_team>
    <visit_score/>
    <forced_home_team>Indiana</forced_home_team>
    <home_score/>
    <forced_period>7:00</forced_period>
    </Sports>
    <Sports>
    <game_id>WNBA-2131244</game_id>
    <league_name1>WNBA</league_name1>
    <forced_visit_team>Seattle</forced_visit_team>
    <visit_score/>
    <forced_home_team>San Antonio</forced_home_team>
    <home_score/>
    <forced_period>10:00</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2105499</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>Cincinnati</forced_visit_team>
    <visit_score/>
    <forced_home_team>Anaheim</forced_home_team>
    <home_score/>
    <forced_period>10:07</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2104920</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>Los Angeles</forced_visit_team>
    <visit_score/>
    <forced_home_team>Arizona</forced_home_team>
    <home_score/>
    <forced_period>9:40</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2103735</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>San Diego</forced_visit_team>
    <visit_score/>
    <forced_home_team>Baltimore</forced_home_team>
    <home_score/>
    <forced_period>7:05</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2103394</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>Chicago WSox</forced_visit_team>
    <visit_score/>
    <forced_home_team>Boston</forced_home_team>
    <home_score/>
    <forced_period>7:10</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2103722</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>Atlanta</forced_visit_team>
    <visit_score/>
    <forced_home_team>Chicago Cubs</forced_home_team>
    <home_score/>
    <forced_period>8:05</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2103977</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>Kansas City</forced_visit_team>
    <visit_score/>
    <forced_home_team>Cleveland</forced_home_team>
    <home_score/>
    <forced_period>7:10</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2104186</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>Texas</forced_visit_team>
    <visit_score/>
    <forced_home_team>Detroit</forced_home_team>
    <home_score/>
    <forced_period>7:10</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2105100</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>Pittsburgh</forced_visit_team>
    <visit_score/>
    <forced_home_team>Houston</forced_home_team>
    <home_score/>
    <forced_period>8:10</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2104307</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>Washington</forced_visit_team>
    <visit_score/>
    <forced_home_team>Miami</forced_home_team>
    <home_score/>
    <forced_period>7:10</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2104792</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>Seattle</forced_visit_team>
    <visit_score/>
    <forced_home_team>Milwaukee</forced_home_team>
    <home_score/>
    <forced_period>8:10</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2104633</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>Tampa Bay</forced_visit_team>
    <visit_score/>
    <forced_home_team>Minnesota</forced_home_team>
    <home_score/>
    <forced_period>8:10</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2103490</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>Toronto</forced_visit_team>
    <visit_score/>
    <forced_home_team>NY Yankees</forced_home_team>
    <home_score/>
    <forced_period>7:05</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2104661</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>NY Mets</forced_visit_team>
    <visit_score/>
    <forced_home_team>Philadelphia</forced_home_team>
    <home_score/>
    <forced_period>7:05</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2105723</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>Colorado</forced_visit_team>
    <visit_score/>
    <forced_home_team>San Francisco</forced_home_team>
    <home_score/>
    <forced_period>9:45</forced_period>
    </Sports>
    <Sports>
    <game_id>MLB-2105140</game_id>
    <league_name1>MLB</league_name1>
    <forced_visit_team>Oakland</forced_visit_team>
    <visit_score/>
    <forced_home_team>St. Louis</forced_home_team>
    <home_score/>
    <forced_period>8:15</forced_period>
    </Sports>
    </DATA>
    </root>
    Attached Files

  • #2
    I send sample for parsing. Keywords about this: Xpath (https://www.w3schools.com/xml/xpath_syntax.asp)
    Attached Files

    Comment


    • #3
      Thanks so much i will look into this.

      Shotski

      Comment


      • #4
        Hi meret,

        i tried your template but it did not load the xml data. It can find the xml file but it is not populating the text fields. I see the GetValue sub but i dont see it triggered anywhere and when i trigger it with a button it does nothing. Any ideas?

        Shotski

        Update: Ok it is reading the data but the list box items do not update, so the leagues stay the same. So if there are no WNBA games it does not remove them from the list since the list box does not update.
        Last edited by Shotski2; 06-28-2019, 01:40 PM.

        Comment


        • #5
          This is example for beginning. If you need different requirement, you have to update it or do you want to meet the demands by me you have to pay price for it.

          Regards.

          Comment


          • #6
            Never mind i figured it out.

            Comment


            • #7
              Hi Everyone,

              I was able to do this in Template Wizard. Is there a way to do it in Viz Artist scripting as well?

              Regards,
              Shotski

              Comment


              • #8
                Hi Shotski,

                Yes you can do it in VSL also. See some XML parsing here:

                http://forum.vizrt.com/forum/general...a-scene-script

                http://forum.vizrt.com/forum/viz-art...accessing-data

                http://forum.vizrt.com/forum/viz-art...859-xml-in-viz

                Comment


                • #9
                  Thanks ravisharma,

                  The last example is what i will try since its closest to what i need. I will give it a try and report back.

                  Thanks again.

                  Comment


                  • #10
                    Ok so i tried to make the code work but no luck. below is what i am trying to parse in XML:

                    <root>
                    <SOURCE>NewsTicker</SOURCE>
                    <REPORT>Currents</REPORT>
                    <RUN_DATE>Wed Jul 3 14:15:31 EDT 2019</RUN_DATE>
                    <DATA>
                    <Currents>
                    <display_name1>Tampa</display_name1>
                    <condition_name1>Thunderstorms</condition_name1>
                    <cond_pic/>
                    <temperature>89</temperature>
                    <wind>SW</wind>
                    <wind_speed>8</wind_speed>
                    <windchill>89</windchill>
                    <hindex>103</hindex>
                    <sunrise>6:38</sunrise>
                    <sunset>8:28</sunset>
                    </Currents>
                    <Currents>
                    <display_name1>Saint Petersburg</display_name1>
                    <condition_name1>Thunderstorms</condition_name1>
                    <cond_pic/>
                    <temperature>78</temperature>
                    <wind>W</wind>
                    <wind_speed>11</wind_speed>
                    <windchill>78</windchill>
                    <hindex>79</hindex>
                    <sunrise>6:38</sunrise>
                    <sunset>8:29</sunset>
                    </Currents>
                    </DATA>
                    </root>

                    Comment


                    • #11
                      (EDITED) Oh i see this thread convo has shifted to viz script parsing. The Thread title is still Parsing in template wizard so will leave this post

                      Check out this template, It will load your XML file and there is a NEXT and PREV button to cycle through the "Current" Packages and pushes to textbox
                      Make sure you have the full path and fileName for the xml file before testing the "Read and Parse" button.

                      -----------------------------------------------------
                      Example code:

                      Dim objXML

                      Set objXML = CreateObject( "Microsoft.XMLDOM" )
                      TWUniMemo2.Lines.LoadFromFile(txtPath.Text)
                      Dim strXML
                      strXML = TWUniMemo2.Text

                      If Not objXML.loadXML(strXML) Then 'strXML is the string with XML'
                      Err.Raise objXML.parseError.ErrorCode, , objXML.parseError.reason
                      End If

                      Dim point
                      Set point = objXML.firstChild

                      txtSource.Text = point.selectSingleNode("SOURCE").Text
                      txtRunDate.Text = point.selectSingleNode("RUN_DATE").Text

                      txtName.Text = point.selectSingleNode("DATA/Currents/display_name1").Text
                      txtTemp.Text = point.selectSingleNode("DATA/Currents/temperature").Text

                      ------------------------------------------------
                      example 2:
                      How to grab data with index as a parameter:



                      Set Nodes = point.SelectSingleNode("DATA").ChildNodes

                      To get the first Currents package you would insert 0 , for next you insert 1, and so forth... You can run it in a loop with the index being fed by the "i" iterator

                      txtName.Text = Nodes(0).SelectSingleNode("display_name1").Text
                      txtTemp.Text = Nodes(0).SelectSingleNode("temperature").Text

                      txtName.Text = Nodes(1).SelectSingleNode("display_name1").Text
                      txtTemp.Text = Nodes(1).SelectSingleNode("temperature").Text
                      Last edited by Novacane89; 07-05-2019, 12:32 PM.

                      Comment


                      • #12
                        Template attached mentioned n post above
                        Attached Files

                        Comment


                        • #13
                          Thanks Novacane. Always a great help.
                          Last edited by Shotski2; 07-05-2019, 01:14 PM.

                          Comment


                          • #14
                            Hi Novacane,

                            Do you have an example of doing the same thing with Artist scripting? I am trying to explore doing things in different ways to see what will work best for our production team.

                            Comment


                            • #15
                              Cool no problem, Yes Viz script can be a bit trickier since you would have to do the parsing manually instead of referencing an existing parser. I will do some testing and let you know if I find a solid solution. It is recommended to do data processing before it enters the viz engine environment for optimal efficiency regarding memory usage.

                              Personally I use C# to prep the data before it is loaded in Viz. For example a small C# console app can monitor the XML file, When XML file updates... The console App can then parse the data to a textfile where it can be read as delimited vars seperated by a "|" for example.

                              So then each package data will occupy a line in the textfile with the data seperated by "|"

                              Dim data

                              Then in viz script you can just do a System.LoadTextFile("TheTextFile",data).

                              Then you split the string by line breaks to get the seperate data packages, and you split by "|" per line to get the individual data elements per package.

                              Comment

                              Working...
                              X