I am working on Windows Phone 8 app development.
i have a xml like the below:
<array>
<dict>
<key>SubTopics</key>
<array>
<dict>
<key>ID</key>
<array>
<string>CD1</string>
<string>CD2</string>
<string>CD3</string>
<string>CD4</string>
</array>
<key>Title</key>
<string>Miscellaneous</string>
<key>Desc</key>
<string> this is just a text</string>
<key>HasItems</key>
<true/>
</dict>
<dict>
<key>ID</key>
<array>
<string>DDC1</string>
<string>DDC2</string>
<string>DDC3</string>
<string>DDC4</string>
<string>DDC5</string>
</array>
<key>Title</key>
<string>Miscellaneous One</string>
<key>Desc</key>
<string> this is just a text</string>
<key>HasItems</key>
<true/>
</dict>
</array>
<key>MainTitle</key>
<string>Data</string>
</dict>
<dict>
<key>SubTopics</key>
<array>
<dict>
<key>ID</key>
<array>
<string>SSD1</string>
<string>SS2</string>
<string>SS3</string>
<string>SS4</string>
</array>
<key>Title</key>
<string>Goblins</string>
<key>Desc</key>
<string> this is just a text</string>
<key>HasItems</key>
<true/>
</dict>
<dict>
<key>ID</key>
<array>
<string>ADC1</string>
<string>ADC2</string>
<string>ADC3</string>
<string>ADC4</string>
<string>DDC5</string>
</array>
<key>Title</key>
<string>Tracks</string>
<key>Desc</key>
<string> this is just a text</string>
<key>HasItems</key>
<true/>
</dict>
</array>
<key>MainTitle</key>
<string>Data Two</string>
</dict>
</array>
How to parse this ?
Its like this :
MainTitle
--SubTitle // list of title
---ID
---Desc
---Boolean Value
MainTitle
--SubTitle //list of values
---ID
---Desc
---Boolean Value
Now in 1st screen i am displaying all the Main Titles
Now on click of Main tile in 1st screen i need all the values of that main title.
So how can i store these a Dictionary<string, List<MyObject>>
?
EDIT
I have tried this:
var dict = (from plist in doc.Root.Element("array").Elements("dict")
select new MyObject
{
MainTitle = (string)plist.Element("string"),
ListOfSubTitles = plist.Element("array")
.Elements("dict")
.Elements("string")
.Select(s => (string)s)
.ToList(),
})
.ToDictionary(a => a.MainTitle, a => a.ListOfSubTitles);
But here its also storing the Desc tag values also in the ListOfSubTitles