I have a xml file like this:
<plist version="1.0">
<array>
<dict>
<key>Title</key>
<string>Chapters</string>
<key>Items</key>
<array>
<dict>
<key>Title</key>
<string>XYZ</string>
</dict>
<dict>
<key>Title</key>
<string>ABC</string>
</dict>
</array>
</dict>
<dict>
<key>Title</key>
<string>ChaptersONE</string>
<key>Items</key>
<array>
<dict>
<key>Title</key>
<string>ASDF</string>
</dict>
</array>
</dict>
</array>
I have a class like this:
class Chapter
{
public string Title { get; set; }
public string SubTitle { get; set; }
}
How do i parse this xml and assign to the Chapter as list ?
I have tried the below :
List<Chapters> List = (from d in doc.Root.Element("array").Elements("dict")
select new HighwayCode
{
Title = (string)d.Element("string"),
SubTitle = d.Element("array")
.Elements("dict")
.Elements("string")
.Select(s => (string)s)
.ToList()
}).ToList();
But here the SubTitle is a list but i need that as a string