Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

Get a heading from an XForm


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?


Feb 18, 2010 14:38

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;

                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);
                if (question.Length == 0)
                    question = "";

            return question;

Feb 22, 2010 9:04
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.