Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Xml;
- namespace fixedAPI_parser
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<Tuple<int, string>> genre_ids_strings = new List<Tuple<int, string>>();
- using (XmlReader xmlReader = XmlReader.Create(@"c:/fixedapi.nfpox"))
- {
- while (xmlReader.Read())
- {
- if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "category"))
- {
- string possible_genre_url =
- xmlReader.GetAttribute("scheme");
- if (possible_genre_url.Contains("genres"))
- {
- //gotta split url for the id
- int genre_id =
- Convert.ToInt32(possible_genre_url.Split('/').Last());
- string genre_string = xmlReader.GetAttribute("label");
- //so long as the group isn't in the list, add it it
- if (
- genre_ids_strings.All(item => item.Item1 != genre_id))
- {
- genre_ids_strings.Add(
- new Tuple<int, string>(genre_id,
- genre_string));
- //Console.WriteLine("added id {0}", genre_id);
- }
- }
- }
- }
- }
- Console.WriteLine("Done, found {0}", genre_ids_strings.Count);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement