public PlistValue GetValue(string path = "") { PlistValue current = Value; if (path == "") { return(Value); } var parse = path.Split('/'); for (int i = 0; i < parse.Length; i++) { var dict = (current as PlistDict); if (dict != null) { PlistValue value; if (!dict.Values.TryGetValue(parse[i], out value)) { return(null); } current = value; continue; } var array = (current as PlistArray); if (array != null) { var index = int.Parse(parse[i]); current = array.Values[index]; continue; } return(null); } return(current); }
public void Read(string filename) { Filename = filename; var xmlReaderSettings = new XmlReaderSettings() { DtdProcessing = DtdProcessing.Parse, IgnoreWhitespace = true, IgnoreComments = true, }; using (var fs = File.OpenRead(filename)) { using (var reader = XmlReader.Create(fs, xmlReaderSettings)) { var readingPlist = false; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (readingPlist) { Value = PlistValue.FromXml(reader); } else { if (reader.Name == "plist") { readingPlist = true; } } } continue; } } } }