I just want to get a string for softwareVersionBundleId and bind version keys, how can I store it in a dictionary so that I can easily get it?
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>genre</key> <string>Application</string> <key>bundleVersion</key> <string>2.0.1</string> <key>itemName</key> <string>AppName</string> <key>kind</key> <string>software</string> <key>playlistName</key> <string>AppName</string> <key>softwareIconNeedsShine</key> <true/> <key>softwareVersionBundleId</key> <string>com.company.appname</string> </dict> </plist>
I tried the following code.
XDocument docs = XDocument.Load(newFilePath); var elements = docs.Descendants("dict"); Dictionary<string, string> keyValues = new Dictionary<string, string>(); foreach(var a in elements) { string key= a.Attribute("key").Value.ToString(); string value=a.Attribute("string").Value.ToString(); keyValues.Add(key,value); }
This is an exception to an object reference.
source share