This documentation is archived and is not being maintained.

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
)
public static String DecodeName (
	String name
)
public static function DecodeName (
	name : String
) : String
Not applicable.

Parameters

name

The name to be transformed.

Return Value

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.

The following example encodes and decodes names.

using System;
using System.IO;
using System.Xml;

public class Sample
{

  public static void Main()
  {

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

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

  }
}

import System.*;
import System.IO.*;
import System.Xml.*;

public class Sample
{
    public static void main(String[] args)
    {
        // Encode and decode a name with spaces.
        String name1 = XmlConvert.EncodeName("Order Detail");
        Console.WriteLine("Encoded name: " + name1);
        Console.WriteLine("Decoded name: " + XmlConvert.DecodeName(name1));
        // Encode and decode a local name.
        String name2 = XmlConvert.EncodeLocalName("a:book");
        Console.WriteLine("Encoded local name: " + name2);
        Console.WriteLine("Decoded local name: " 
            + XmlConvert.DecodeName(name2));
    } //main 
} //Sample

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0
Show: