Gets or sets the value of this attribute.
Assembly: System.Xml.Linq (in System.Xml.Linq.dll)
You can use this property to get or set the value of an attribute.
If you are getting the value and the attribute might not exist, it is more convenient to use the explicit conversion operators, and assign the attribute to a nullable type such as string or Nullable<T> of Int32. If the attribute does not exist, then the nullable type is set to null. Before using this property, you must make sure that the Attribute method does not return null.
The following example creates an element with an attribute. It then retrieves the value of the attribute, and then sets it.
Note that the Visual Basic example uses the XML attribute property.
StringBuilder output = new StringBuilder(); XElement root = new XElement("Root", new XAttribute("Att", "content") ); XAttribute att = root.FirstAttribute; output.Append(att.Value + Environment.NewLine); att.Value = "new text"; output.Append(att.Value + Environment.NewLine); OutputTextBlock.Text = output.ToString();
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.