将 XML 数据类型映射到 CLR 类型

下表介绍 XML 数据类型与公共语言运行库 (CLR) 类型之间的默认映射。

下表介绍 XML 数据类型与 CLR 类型的默认映射。

注意注意

xs 和 xdt 前缀分别映射到 http://www.w3.org/2001/XMLSchema 和 http://www.w3.org/2003/05/xpath-datatypes 命名空间 URI。

XML 类型

CLR 类型

xs:anyURI

Uri

xs:base64Binary

Byte[]

xs:boolean

Boolean

xs:byte

SByte

xs:date

DateTime

xs:dateTime

DateTime

xs:decimal

Decimal

xs:double

Double

xs:duration

TimeSpan

xs:ENTITIES

String[]

xs:ENTITY

String

xs:float

Single

xs:gDay

DateTime

xs:gMonthDay

DateTime

xs:gYear

DateTime

xs:gYearMonth

DateTime

xs:hexBinary

Byte[]

xs:ID

String

xs:IDREF

String

xs:IDREFS

String[]

xs:int

Int32

xs:integer

Decimal

xs:language

String

xs:long

Int64

xs:gMmonth

DateTime

xs:Name

String

xs:NCName

String

xs:negativeInteger

Decimal

xs:NMTOKEN

String

xs:NMTOKENS

String[]

xs:nonNegativeInteger

Decimal

xs:nonPositiveInteger

Decimal

xs:normalizedString

String

xs:NOTATION

XmlQualifiedName

xs:positiveInteger

Decimal

xs:QName

XmlQualifiedName

xs:short

Int16

xs:string

String

xs:time

DateTime

xs:token

String

xs:unsignedByte

Byte

xs:unsignedInt

UInt32

xs:unsignedLong

UInt64

xs:unsignedShort

UInt16

xdt:dayTimeDuration

TimeSpan

xdt:yearMonthDuration

TimeSpan

xdt:untypedAtomic

String

xdt:anyAtomicType

Object

xs:anySimpleType

String

Document 节点

XPathNavigator

Element 节点

XPathNavigator

Attribute 节点

XPathNavigator

Namespace 节点

XPathNavigator

Text 节点

XPathNavigator

Comment 节点

XPathNavigator

Processing Instruction 节点

XPathNavigator

请参见

其他资源

System.Xml 类中的类型支持