System.Xml.XmlConvert.DecodeName Method

Decodes a name. This method does the reverse of the XmlConvert.EncodeName(string) and XmlConvert.EncodeLocalName(string) methods.

Syntax

public static string DecodeName (string name)

Parameters

name
The name to be transformed.

Returns

The decoded name.

Remarks

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.

Note:

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.

Example

The following example demonstrates the valid and invalid character formats for decoding.

C# Example

using System;
using System.Xml;

public class App {

  public static void Main() {

    Console.WriteLine( "{0} : {1} : {2}",
      // _x0069_ decodes to i
      XmlConvert.DecodeName("Order #1_x0069_"),

      // missing beginning _
      XmlConvert.DecodeName("Order #1x0069_"),

      // short form
      XmlConvert.DecodeName("Order #1_x69_") ); 
  }
}
   

The output is

Order #1i : Order #1x0069_ : Order #1_x69_

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0