<PackageReference Include="System.Xml.ReaderWriter" Version="4.0.11-beta-23409" />

XmlConvert

public static class XmlConvert
Encodes and decodes XML names, and provides methods for converting between common language runtime types and XML Schema definition language (XSD) types. When converting data types, the values returned are locale-independent.
public static string DecodeName(string name)

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

public static string EncodeLocalName(string name)

Converts the name to a valid XML local name.

public static string EncodeName(string name)

Converts the name to a valid XML name.

public static string EncodeNmToken(string name)

Verifies the name is valid according to the XML specification.

public static bool ToBoolean(string s)

Converts the String to a Boolean equivalent.

public static byte ToByte(string s)

Converts the String to a Byte equivalent.

public static char ToChar(string s)

Converts the String to a Char equivalent.

public static DateTime ToDateTime(string s, XmlDateTimeSerializationMode dateTimeOption)

Converts the String to a DateTime using the XmlDateTimeSerializationMode specified

public static DateTimeOffset ToDateTimeOffset(string s)

Converts the supplied String to a DateTimeOffset equivalent.

public static DateTimeOffset ToDateTimeOffset(string s, string format)

Converts the supplied String to a DateTimeOffset equivalent.

public static DateTimeOffset ToDateTimeOffset(string s, string[] formats)

Converts the supplied String to a DateTimeOffset equivalent.

public static decimal ToDecimal(string s)

Converts the String to a Decimal equivalent.

public static double ToDouble(string s)

Converts the String to a Double equivalent.

public static Guid ToGuid(string s)

Converts the String to a Guid equivalent.

public static short ToInt16(string s)

Converts the String to a Int16 equivalent.

public static int ToInt32(string s)

Converts the String to a Int32 equivalent.

public static long ToInt64(string s)

Converts the String to a Int64 equivalent.

public static sbyte ToSByte(string s)

Converts the String to a SByte equivalent.

public static float ToSingle(string s)

Converts the String to a Single equivalent.

public static string ToString(bool value)

Converts the Boolean to a String.

public static string ToString(char value)

Converts the Char to a String.

public static string ToString(decimal value)

Converts the Decimal to a String.

public static string ToString(sbyte value)

Converts the SByte to a String.

public static string ToString(short value)

Converts the Int16 to a String.

public static string ToString(int value)

Converts the Int32 to a String.

public static string ToString(long value)

Converts the Int64 to a String.

public static string ToString(byte value)

Converts the Byte to a String.

public static string ToString(ushort value)

Converts the UInt16 to a String.

public static string ToString(uint value)

Converts the UInt32 to a String.

public static string ToString(ulong value)

Converts the UInt64 to a String.

public static string ToString(float value)

Converts the Single to a String.

public static string ToString(double value)

Converts the Double to a String.

public static string ToString(TimeSpan value)

Converts the TimeSpan to a String.

public static string ToString(DateTime value, XmlDateTimeSerializationMode dateTimeOption)

Converts the DateTime to a String using the XmlDateTimeSerializationMode specified.

public static string ToString(DateTimeOffset value)

Converts the supplied DateTimeOffset to a String.

public static string ToString(DateTimeOffset value, string format)

Converts the supplied DateTimeOffset to a String in the specified format.

public static string ToString(Guid value)

Converts the Guid to a String.

public static TimeSpan ToTimeSpan(string s)

Converts the String to a TimeSpan equivalent.

public static ushort ToUInt16(string s)

Converts the String to a UInt16 equivalent.

public static uint ToUInt32(string s)

Converts the String to a UInt32 equivalent.

public static ulong ToUInt64(string s)

Converts the String to a UInt64 equivalent.

public static string VerifyName(string name)

Verifies that the name is a valid name according to the W3C Extended Markup Language recommendation.

public static string VerifyNCName(string name)

Verifies that the name is a valid NCName according to the W3C Extended Markup Language recommendation. An NCName is a name that cannot contain a colon.

public static string VerifyNMTOKEN(string name)

Verifies that the string is a valid NMTOKEN according to the W3C XML Schema Part2: Datatypes recommendation

public static string VerifyPublicId(string publicId)

Returns the passed in string instance if all the characters in the string argument are valid public id characters.

public static string VerifyWhitespace(string content)

Returns the passed-in string instance if all the characters in the string argument are valid whitespace characters.

public static string VerifyXmlChars(string content)

Returns the passed-in string if all the characters and surrogate pair characters in the string argument are valid XML characters, otherwise an XmlException is thrown with information on the first invalid character encountered.