我正在尝试构建一个XML文件,该文件读取要放入列表中的内容:ListtrashFoods当我创建XML文件时,它将是这样的:XDocumentdoc=newXDocument(newXDeclaration("1.0","utf-8","yes"),newXComment(""),newXElement("Snacks",trashFoods.Select(snack=>newXElement("Type",snack.Type),newXElement("Name",snack.Name)),)我想做但我做不到的是将条件语句放入XML文件的结构中。类似这样:XDocumentdoc=