Announcement

Collapse
No announcement yet.

DataReader help getting the right information

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

  • DataReader help getting the right information

    Hello and thanks for any help.

    I have the XML show bellow,

    I am using DataReader to read the info from it using the following

    DataReader Sample.PNG

    I am using "race_name1' as the key to read all the election info which then I send to a DataTable
    (is there another way to accomplish this??)


    I then pass the info to a dataobject using the Input Value of "President"

    data object sample.PNG

    this is then passed to a datatext, using the node names, all this node names I added to the config.dp as shown in the Table above


    my tree looks like this

    tree sample.PNG

    As you can see I am reading or getting the "race_name1" on the first container under the dataobject, this is displaying the correct information, which is the name of the race.

    The problem is with the second and third text container which display the information from the 3rd "Elections" from the XML, please see the note bellow



    I need help figuring our how do I get to display any of the other nodes, in the first or second "Elections" from the xml, as I am using the name of the race as the key to read the xml, I think datapool is skipping the first two "Elections" and is only returning the last "Elections"
    The xml is much larger, this is only a sample, so I have other races that have more than 2 candidates so the race name is duplicated to accommodate this and I get the same result, I am only getting the last race with that name.

    Again thanks and let me know if you need more info to give me some help

    HTML Code:
    <Elections>
          <race_name1>President</race_name1>
          <race_name2></race_name2>
          <pct_precincts_reporting>100</pct_precincts_reporting>
          <cand1_first_name>Donald</cand1_first_name>
          <cand1_last_name>Trump</cand1_last_name>
          <cand1_winner>Y</cand1_winner>
          <cand1_vote_total>4076538</cand1_vote_total>
          <cand1_pct_total>45</cand1_pct_total>
          <cand1_party_name1>GOP</cand1_party_name1>
          <cand1_pic_id></cand1_pic_id>
          <cand1_full_name>Donald Trump</cand1_full_name>
          <cand2_first_name>Hillary</cand2_first_name>
          <cand2_last_name>Clinton</cand2_last_name>
          <cand2_winner></cand2_winner>
          <cand2_vote_total>3643971</cand2_vote_total>
          <cand2_pct_total>40</cand2_pct_total>
          <cand2_party_name1>DEM</cand2_party_name1>
          <cand2_pic_id></cand2_pic_id>
          <cand2_full_name>Hillary Clinton</cand2_full_name>
       </Elections>
       <Elections>
          <race_name1>President</race_name1>
          <race_name2></race_name2>
          <pct_precincts_reporting>100</pct_precincts_reporting>
          <cand1_first_name>Gary</cand1_first_name>
          <cand1_last_name>Johnson</cand1_last_name>
          <cand1_winner></cand1_winner>
          <cand1_vote_total>783915</cand1_vote_total>
          <cand1_pct_total>9</cand1_pct_total>
          <cand1_party_name1>LIB</cand1_party_name1>
          <cand1_pic_id></cand1_pic_id>
          <cand1_full_name>Gary Johnson</cand1_full_name>
          <cand2_first_name>Jill</cand2_first_name>
          <cand2_last_name>Stein</cand2_last_name>
          <cand2_winner></cand2_winner>
          <cand2_vote_total>438955</cand2_vote_total>
          <cand2_pct_total>5</cand2_pct_total>
          <cand2_party_name1>GRN</cand2_party_name1>
          <cand2_pic_id></cand2_pic_id>
          <cand2_full_name>Jill Stein</cand2_full_name>
       </Elections>
       <Elections>
          <race_name1>President</race_name1> -------------------------> this is the name that appears in the output
          <race_name2></race_name2>
          <pct_precincts_reporting>100</pct_precincts_reporting>
          <cand1_first_name>Gloria</cand1_first_name>
          <cand1_last_name>Riva</cand1_last_name>
          <cand1_winner></cand1_winner>
          <cand1_vote_total>182518</cand1_vote_total>
          <cand1_pct_total>2</cand1_pct_total>
          <cand1_party_name1>P&amp;F</cand1_party_name1>
          <cand1_pic_id></cand1_pic_id>
          <cand1_full_name>Gloria Riva</cand1_full_name>   -------------------------> this is the name that appears in the output
          <cand2_first_name></cand2_first_name>
          <cand2_last_name></cand2_last_name>
          <cand2_winner></cand2_winner>
          <cand2_vote_total></cand2_vote_total>
          <cand2_pct_total></cand2_pct_total>
          <cand2_party_name1></cand2_party_name1>
          <cand2_pic_id></cand2_pic_id>
          <cand2_full_name></cand2_full_name>
       </Elections>
    Attached Files

  • #2
    Hey matzunaga, try these files.
    In the RAR, there is one via file, one XML and a DP file. And I am getting all the data elements. Hope it will be of some help.
    Attached Files

    Comment


    • #3
      Ravi,

      Thanks for the reply.

      I see that you can display all the elements from the XML, any idea on how to display only certain elements and not all.

      In our XML we have 150 races, but I do not want to include all races, only 25, but the races do not appear one after another in the XML.

      Do I have to create all the races in artist and turn them ON of OFF as needed?

      or is there a way to get specific races without having to create all 150 and turn 1 ON and the rest OFF?

      Again thanks for any help

      Comment


      • #4
        Hi Matzunaga,

        I think you have to use From Row and Numbers of Rows fields in the DataReader and with multiple instances. I haven't tried other options. Anyone else is listening???

        Comment


        • #5
          Originally Posted by ravisharma View Post
          Hey matzunaga, try these files.
          In the RAR, there is one via file, one XML and a DP file. And I am getting all the data elements. Hope it will be of some help.
          Hi, I'm trying to get DataReader working with JSON files, and I figured I could use this as a base. I converted the xml file to a json using on online utility, validated it and then changed DataReader to JSON, and pointed it to the new file - leaving all the other settings you had in DataReader the same. Unfortunately, I get "Error parsing JSON:"

          Attached is the converted json file (remove the '.txt' in the filename - I couldn't upload without adding that).

          Any clue what's going on, or does anyone have a working example of using DataReader with a JSON file they could share with me?

          Thanks,
          -Rich
          Attached Files

          Comment


          • #6
            Hello Rich,

            I have not had the chance to work with a JSON file, the info I get with DataReader comes to me as an XML, sorry and good luck

            Comment


            • #7
              Hi richhelvey I tested with your .json file and it works. Maybe because I put the file on the desktop C:\Users\xxxxxxx\Desktop\onair.json, the path can be a problem sometimes. I used the DataReader.rar file from ravisharma and changed only the Query type to JSON

              Comment

              Working...
              X