我正在尝试创建一个读取xml的泛型方法,并将节点名称和属性值作为字典项返回。
我一直在使用语法,但似乎无法完全正确。 我在这里缺少什么?
目前我有:
XElement doc = XElement.Load(dataStream);
var item = from el in doc.Descendants()
where el.Attribute(attributeName) != null
select new
{
Name = el.Name.LocalName,
Value = el.Attribute(attributeName).Value
}.ToDictionary(o => o.Name, o => o.Value);
答案 0 :(得分:2)
您应该用括号包装LINQ查询:
@IBAction func detailAdd(sender: AnyObject) {
if let dvc : DetailViewController = detailViewController {
dvc.displayOverlay()
} else {
print("Oops...no detail controller")
}
}