Linq to XML with nested Dictionary and Array

前端 未结 2 2033
清酒与你
清酒与你 2020-12-12 08:17

I am Working on Windows Phone 8 application:

I have a document like this :


    
        SubTopics
           


        
2条回答
  •  情书的邮戳
    2020-12-12 08:47

    I used Hakan's Parser class almost straight out of the box: I needed an integer element but no true or false - simple edits. This snippet might help people test their code. I have renamed some of Hakan's symbols to fit my project.

    private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            List> topicsList = topicParser.Parse(topicsXDocument.Root);
            Console.WriteLine("The Topics List contains:");
            foreach (Dictionary topic in topicsList)
            {
                foreach (KeyValuePair element in topic)
                {
                    string name = element.Key;
                    object content = element.Value;
                    Console.WriteLine("Key: {0}, Value: {1}", name, content.ToString());
                }
            }
    
        }
    

提交回复
热议问题