Mono Class Library: System.Xml Namespace

System.Xml.XmlConvert Class

Encodes and decodes XML names and provides methods for converting between common language infrastructure (CLI) types and XML Schema Definition language (XSD) types. When converting data types, the values returned are locale independent. [Edit]

See Also: XmlConvert Members

public class XmlConvert

Thread Safety

All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.

Remarks

Element and attribute names or ID values are limited to a range of XML characters according to the Extensible Markup Language (XML) 1.0 (Second Edition) recommendation, located at www.w3.org/TR/2000/REC-xml-20001006.html. When names contain invalid characters, they need to be translated into valid XML names.

Many languages and applications allow Unicode characters in their names, which are not valid in XML names. For example, if 'Order Detail' were a column heading in a database, the database allows the space between the words Order and Detail. However, in XML, the space between Order and Detail is considered an invalid XML character. Thus, the space, the invalid character, needs to be converted into an escaped hexadecimal encoding and can be decoded later.

The XmlConvert.EncodeName(string) and XmlConvert.DecodeName(string) methods are used to translate invalid XML names into valid XML names and vice versa.

System.Xml.XmlConvert provides methods that enable the conversion of a string to a CLI data type and vice-versa. Locale settings are not taken into account during data conversion.

System.Xml.XmlConvert also provides methods that convert between XML Schema Definition (XSD) data types (see http://www.w3.org/TR/xmlschema-2/#built-in-datatypes) and their corresponding common language infrastructure (CLI) data types. The following table shows the XSD data types and their corresponding CLI data types.

XSD data typeCLI data type
hexBinaryA byte array
base64BinaryA byte array
Booleanbool
Bytesbyte
normalizedStringstring
DateDateTime
durationTimeSpan
dateTimeDateTime
decimaldecimal
Doubledouble
ENTITIESA string array
ENTITYstring
Floatfloat
gMonthDayDateTime
gDayDateTime
gYearDateTime
gYearMonthDateTime
IDstring
IDREFstring
IDREFSA string array
intint
integerdecimal
languagestring
longlong
monthDateTime
Namestring
NCNamestring
negativeIntegerdecimal
NMTOKENstring
NMTOKENSA string array
nonNegativeIntegerdecimal
nonPositiveIntegerdecimal
NOTATIONstring
positiveIntegerdecimal
shortshort
stringstring
timeDateTime
timePeriodDateTime
tokenstring
unsignedBytebyte
unsignedIntuint
unsignedLongulong
unsignedShortushort
anyURIUri
[Edit]

Requirements

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