Zannith Zannith - 9 months ago 71
C# Question

retrieve xml type string

I am using xml to linq but cannot find a way to retrieve the string "thing" in the following code:

<element type = "thing">

here is my c# code

foreach (XElement q in xdoc.Descendants("question"))
name = #need syntax here to retrieve the type
text = q.Element("questiontext").Element("text").Value.ToString();
if (name == "truefalse")
qList.Add(Question.makeType(name, text));


Something like the following should work to find all the "truefalse" type questions.

var questions = 
   from question in xDoc.Descendants("question")
   where question.Attribute("type").Equals("truefalse")
   select question;