Home All Groups Group Topic Archive Search About
Author
16 Aug 2006 8:50 PM
Roy
I have an xml file with the data types for elements and attributes defined in
xsd. If I load the xml in XmlDocument, How do I get the element and attribute
values in its >NET types. For example, I have an Age (could be element or
attribute) which is defined as 2 byte interger in xsd. After I load the xml
in XmlDocument, how do I get the value as Int16 .NET data type when going
through the XmlNode?

Author
20 Aug 2006 1:06 AM
Dave Sexton
Hi Roy,

Try using the XmlReader.Create() method to obtain an XmlReader.  The XmlReader class provides a method named ReadContentAs that
accepts a Type and returns an object.  To identify the data type of the current node as defined in the schema try using the
following code:

    reader.SchemaInfo.SchemaType.TypeCode

where reader is an XmlReader instance that is validating your XmlSchema.  You can assign your schema to the reader in the Create
method using an XmlReaderSettings object.

XmlReader.Create on MSDN:
http://msdn2.microsoft.com/en-US/library/system.xml.xmlreader.create.aspx

--
Dave Sexton

Show quote
"Roy" <R**@discussions.microsoft.com> wrote in message news:C9B7323B-8CC6-49D6-8E56-A5F59B60D7DC@microsoft.com...
>I have an xml file with the data types for elements and attributes defined in
> xsd. If I load the xml in XmlDocument, How do I get the element and attribute
> values in its >NET types. For example, I have an Age (could be element or
> attribute) which is defined as 2 byte interger in xsd. After I load the xml
> in XmlDocument, how do I get the value as Int16 .NET data type when going
> through the XmlNode?
>

AddThis Social Bookmark Button