Your Digital Media Has Never Looked So Good

 
pdineshkumar55
Topic Author
Posts: 29
Joined: Thu Jun 25, 2015 12:56 am

Get the unique values in array

Wed Jul 01, 2015 5:31 am

Hi Everyone,

I am using xml to get the videos from rss feed and in need to show it in Grid screen.

And I am getting the categories list in array with duplicate values while reading the all category tags in xml.

For example,
<rss>
  <channel>
    <item>
        <category>Music</category>
        <title>Good Morning</title>
        <url/>
    </item>
        <category>Music</category>
        <title>Good Morning People</title>
        <url/>
    <item/>
        <category>Entertainment</category>
        <title>Entertainment unchecked</title>
        </url>
    <item/>
  </channel>
</rss>


Like this. So, How can I get the unique category names only in the list.

Or is that any method to get unique values from the array.

Anyone please help.

Thank you.
I am using Roku 4 - 4400X Model.
 
sjb64
Posts: 108
Joined: Thu Apr 16, 2015 1:13 pm
Location: Memphis, TN

Re: Get the unique values in array

Wed Jul 01, 2015 5:50 am

My first thought would be load them into an associative array as the keys, which enforces unique values. You could check for existence first and not add duplicates, or just go ahead and add them (using addreplace), which just becomes a replace. Either way you then walk the keys (for each) and have the distinct values.
FlixRaider channel
 
pdineshkumar55
Topic Author
Posts: 29
Joined: Thu Jun 25, 2015 12:56 am

Re: Get the unique values in array

Wed Jul 01, 2015 6:56 am

Yes, You are right..

Using roAssociativeArray removed the duplicates.

Thank you very much.
I am using Roku 4 - 4400X Model.

Who is online

Users browsing this forum: No registered users and 3 guests