I found a way to do this from a link that I can't seem to find at the moment so if anybody know what site this could be the author would probably appreciate the credit. :)
public string GetQuestion(PageData page)
{
XForm form = XForm.CreateInstance(new Guid((String)page["XForm"]));
SerializableXmlDocument doc = form.Document;
XDocument xmlDoc = XDocument.Parse(doc.InnerXml);
string question = string.Empty;
try
{
var headingQuery = from q in xmlDoc.Descendants("span")
where q.Attribute("class").Value.Contains("Heading")
select new { heading = q.Value };
question = (string)(headingQuery.ElementAt(0).heading);
}
finally
{
if (question.Length == 0)
question = "";
}
return question;
}
I've created a poll XForm containing a heading with a question, a set of radio buttons for alternatives and a button to submit to the poll. I'd like to extract the heading of that XForm that represents the question. How would I do that? I've gotten as far as to create an instance of the XForm by XForm form = XForm.CreateInstance(new Guid((String)page["XForm"])); but is it now possible to get parts of that XForm out of it?