|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
.NET Xml questionI 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? 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 -- Show quoteDave Sexton "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? > |
|||||||||||||||||||||||