このコードは私には機能せず、その理由がわかりません。
xmlDoc.Element("results").Add(
new XElement("user",
new XAttribute("id", user.Id),
new XAttribute("facebookid", user.FacebookId),
new XAttribute("email", user.Email),
new XAttribute("totalpoints", totalpoints)
).Add(
user.Answers.Select(value => new XElement("question",
new XAttribute("id", value.QuestionId),
new XAttribute("answer_id", value.AnswerId),
new XAttribute("points", value.Points)))
)
);
私はこれを作成しようとしています
<results>
<user id="2323" facebookId="3254954795743957" email="david@gmail" totalPoints="">
<question id="1" answer_id="3" points="0" />
<question id="2" answer_id="1" points="1" />
</user>
</results>