all groups > dotnet xml > july 2006 >
You're in the

dotnet xml

group:

Data types for XmlElement and XmlAttribute


Data types for XmlElement and XmlAttribute Roy
7/18/2006 6:24:01 AM
dotnet xml:
I have an XmlDocument loaded from an xml file. I have also an xsd schema file
associated with it so that it will be in the XmlSchemaSet.
How do I get the data type for the value of an XmlElement and XmlAttribute
as described in the schema while I am accessing the nodes (attributes and
Re: Data types for XmlElement and XmlAttribute Roy
7/18/2006 8:56:01 AM
Is there any support in .Net to get the value (for both attribute and
element) in its defined types?
The value for XmlAttribute alway gives a string for example. If it is
defined as an interger in xsd, I would like to get it as an interger. Or I
have to write my code to convert it for every types from string.

[quoted text, click to view]
Re: Data types for XmlElement and XmlAttribute Priya Lakshminarayanan
7/18/2006 10:05:15 AM
If you use an XPathNavigator over the XmlDocument, then you can get typed
values (typed according to the schema) using the following properties on the
navigator:
TypedValue Property
ValueAsBoolean Property
ValueAsDateTime Property
ValueAsDouble Property
ValueAsInt Property
ValueAsLong Property

Thanks,
Priya

[quoted text, click to view]

Re: Data types for XmlElement and XmlAttribute Martin Honnen
7/18/2006 3:30:33 PM


[quoted text, click to view]

That is possible in .NET 2.0, see the property SchemaInfo
<http://msdn2.microsoft.com/en-us/library/system.xml.xmlelement.schemainfo.aspx>
<http://msdn2.microsoft.com/en-us/library/system.xml.schema.ixmlschemainfo.aspx>

--

Martin Honnen --- MVP XML
AddThis Social Bookmark Button