Export (0) Print
Expand All

XAttribute.ToString Method

Converts the current XAttribute object to a string representation.

Namespace:  System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)

public override string ToString()

Return Value

Type: System.String
A String containing the XML text representation of an attribute and its value.

This method returns a string in the form of AttributeName="content".

The following example creates an element with several attributes. It then gets an attribute and displays it and its content by calling this method.


StringBuilder output = new StringBuilder();
XElement root = new XElement("Root",
    new XAttribute("Att1", "content1"),
    new XAttribute("Att2", "content2"),
    new XAttribute("Att3", "content3")
);
XAttribute att = root.Attribute("Att2");
output.Append(att.ToString());
output.Append(Environment.NewLine);

OutputTextBlock.Text = output.ToString();


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2015 Microsoft