XmlConvert.DecodeName(String) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Decodes a name. This method does the reverse of the EncodeName(String) and EncodeLocalName(String) methods.
public:
static System::String ^ DecodeName(System::String ^ name);
public static string DecodeName (string name);
public static string? DecodeName (string? name);
static member DecodeName : string -> string
Public Shared Function DecodeName (name As String) As String
- name
- String
The name to be transformed.
The decoded name.
The following example encodes and decodes names.
#using <System.dll>
#using <System.XML.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
// Encode and decode a name with spaces.
String^ name1 = XmlConvert::EncodeName( "Order Detail" );
Console::WriteLine( "Encoded name: {0}", name1 );
Console::WriteLine( "Decoded name: {0}", XmlConvert::DecodeName( name1 ) );
// Encode and decode a local name.
String^ name2 = XmlConvert::EncodeLocalName( "a:book" );
Console::WriteLine( "Encoded local name: {0}", name2 );
Console::WriteLine( "Decoded local name: {0}", XmlConvert::DecodeName( name2 ) );
}
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));
}
}
Imports System.IO
Imports System.Xml
public class Sample
public shared sub Main()
' Encode and decode a name with spaces.
Dim name1 as string = XmlConvert.EncodeName("Order Detail")
Console.WriteLine("Encoded name: " + name1)
Console.WriteLine("Decoded name: " + XmlConvert.DecodeName(name1))
' Encode and decode a local name.
Dim name2 as string= XmlConvert.EncodeLocalName("a:book")
Console.WriteLine("Encoded local name: " + name2)
Console.WriteLine("Decoded local name: " + XmlConvert.DecodeName(name2))
end sub
end class
The names are decoded using the following rules:
Names are decoded from left to right.
Any sequence _xHHHH_ (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.
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: