Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void XmlTest()
- {
- Stopwatch sw = new Stopwatch();
- string XmlFilePath = "TOROKORSZAG39.xml";
- Console.WriteLine("Nyomjunk egy billentyűt a kezdéshez!" + Environment.NewLine + "Beolvasandó fájl: " + XmlFilePath);
- Console.ReadKey();
- Dictionary<string, List<string>> travel_data = new Dictionary<string, List<string>>();
- sw.Start();
- string id = "";
- using (XmlReader xmlReader = XmlReader.Create(XmlFilePath))
- {
- while (xmlReader.Read())
- {
- if (xmlReader.Name == "code")
- {
- id = (XNode.ReadFrom(xmlReader) as XElement).Value;
- travel_data.Add(id, new List<string>());
- }
- /*if (xmlReader.Name == "name")
- {
- XElement item = XNode.ReadFrom(xmlReader) as XElement;
- Console.WriteLine(id + " :: " + item.Value);
- }*/
- if (id != "" && (xmlReader.Name == "name" || xmlReader.Name == "id" || xmlReader.Name == "code" || xmlReader.Name == "region"))
- {
- travel_data[id].Add(xmlReader.Value);
- }
- }
- }
- sw.Stop();
- Console.WriteLine("=== Kész! " + String.Format("{0:00}:{1:00}:{2:00}.{3:00}", sw.Elapsed.Hours, sw.Elapsed.Minutes, sw.Elapsed.Seconds, sw.Elapsed.Milliseconds/10) + " ===");
- foreach(KeyValuePair<string,List<string>> item in travel_data)
- {
- List<string> data = item.Value;
- Console.WriteLine(item.Key);
- foreach (string datavalue in data)
- {
- Console.WriteLine(datavalue.ToString());
- }
- Console.WriteLine("=====");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement