Export (0) Print
Expand All

XmlConvert.DecodeName Method

Decodes a name. This method does the reverse of the EncodeName and EncodeLocalName methods.

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

public static string DecodeName(
	string name
)

Parameters

name
Type: System.String
The name to be transformed.

Return Value

Type: System.String
The decoded name.

The names are decoded using the following rules:

  • Names are decoded from left to right.

  • Any sequence _x HHHH_ (where HHHH stands for a valid, four digit hexadecimal UCS-2 code) that has not been decoded is transformed into the corresponding Unicode 2.1 (Unicode 3.0 if supported by the application) character.

  • No shortforms are recognized. They are passed on without translation. For example, _x20_ or __ are not decoded.

NoteNote:

The actual encoding of the character is application-specific. For example, Order_x0020_Details becomes Order Details. Even escaped characters that are invalid in XML names will be recognized and decoded.



StringBuilder output = new StringBuilder();
// Encode and decode a name with spaces.
string name1 = XmlConvert.EncodeName("Order Detail");
output.AppendLine("Encoded name: " + name1 );
output.AppendLine("Decoded name: " + XmlConvert.DecodeName(name1));

// Encode and decode a local name.
string name2 = XmlConvert.EncodeLocalName("a:book");
output.AppendLine("Encoded local name: " + name2);
output.AppendLine("Decoded local name: " + XmlConvert.DecodeName(name2));

// Display the output to the TextBlock control
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:
© 2014 Microsoft