Luke

Luke

  • NA
  • 13
  • 0

Parsing XML dict file using xlinq

Mar 25 2008 7:32 PM

I am trying to parse a file (iTunes playlist) using XLinq, but the way the dictionary is setup in the file is causing issue.  Its looking for an element called Name, and not looking at key/value combo.    Anybody know how to fix the issue?

 

TextReader reader = new StreamReader(filepath);

XMLList. = XElement.Load(reader);

foreach (XElement x in XMLList.Elements("dict"))

{

   Song s = new Song{Name=(string)x.Element("Name")};

}

File looks like.....

<plist version="1.0">
   <key>860</key>

    <dict>
      <key>TrackID</key>
      <integer>1017</integer>
      <key>Name</key>
      <string>Stage</string>
      <key>Artist</key>
      <string>Live</string>
      <key>Composer</key>
      <string>Ed Kowalczyk, Chad Taylor, Patrick Dahlheimer, Chad Gracey</string>
      <key>Album</key>
      <string>Throwing Copper</string>


Answers (1)