using System.Collections.Generic;
public Int32 FormElementId { get; set; }
public String FormElementName { get; set; }
public class FormPageElement
public Int32 FormPageElementId { get; set; }
public Int32 FormElementId { get; set; }
public static void Main()
String xmlString = "<FormData>" +
" <Info UserCreated=\"GUID\" />" +
" <FormElement formElementId=\"1\" fieldTypeId=\"1\" text=\"aaa\" />" +
" <FormElement formElementId=\"2\" fieldTypeId=\"2\" text=\"bbb\" />" +
" <FormElement formElementId=\"3\" fieldTypeId=\"3\" selectedIndex=\"\" selectedText=\"\" />" +
" <FormElement formElementId=\"4\" fieldTypeId=\"4\" time=\"\" />" +
" <FormElement formElementId=\"5\" fieldTypeId=\"5\" date=\"\" />" +
" <FormElement formElementId=\"6\" fieldTypeId=\"6\" signatureImageData=\"\" signaturePoints=\"\" />" +
" <FormElement formElementId=\"7\" fieldTypeId=\"7\" latitude=\"\" longitude=\"\" />" +
" <FormElement formElementId=\"8\" fieldTypeId=\"8\" imageData=\"\" imageFilepath=\"\" annotationImageData=\"\" annotationPoints=\"\" />" +
" <FormElement formElementId=\"9\" fieldTypeId=\"1\" text=\"ccc\" />" +
XDocument xDoc = XDocument.Parse(xmlString);
XElement element = xDoc.Descendants().Elements("FormElement").Single(x => x.Attribute("formElementId").Value == formElementId.ToString());
element.SetAttributeValue("text", text);
Console.WriteLine(xDoc.ToString());