strong type in XML
-
how to do the following using .NET I have the following XML document : 3.14159 If I were using COM MSXML parser, I could get NodeTypedValue property to get "strongly-typed" value. b= XMLDocument.SelectSingleNode("//b"); variant value = b.NodeTypedValue; //now the variant contains double value. The question is: how to achieve the same using C# ? Value property of XMLNode object returns String type, wchich i have to convert to get desired type... How to do this without explicit conversion (by the means of XMLConvert class or similar...) Thanks Michal Januszczyk
-
how to do the following using .NET I have the following XML document : 3.14159 If I were using COM MSXML parser, I could get NodeTypedValue property to get "strongly-typed" value. b= XMLDocument.SelectSingleNode("//b"); variant value = b.NodeTypedValue; //now the variant contains double value. The question is: how to achieve the same using C# ? Value property of XMLNode object returns String type, wchich i have to convert to get desired type... How to do this without explicit conversion (by the means of XMLConvert class or similar...) Thanks Michal Januszczyk
May be that's me but I believe that even with MSXML you are supposed to have a separate schema (with attributes of the form dt:type="int") to define node data types. May be for usability reasons MS indeed allowed to put dt:type attributes along with Xml elements, but that of course didn't apply to define attribute data types since an attribute can hardly be data typed by another attribute. It's not lost with the .NET Xml parser, just made different. The Xml schema has its own namespace and has the equivalent API you referred to, scattered in this namespace. For instance,
System.Xml.Schema.XmlSchemaDatatype.ParseValue()
. PS : the .NET Xml parser is not a wrapper of the MSXML parser, which is a very good design decision. (at least something that stands for itself in this .NET run-time). -
May be that's me but I believe that even with MSXML you are supposed to have a separate schema (with attributes of the form dt:type="int") to define node data types. May be for usability reasons MS indeed allowed to put dt:type attributes along with Xml elements, but that of course didn't apply to define attribute data types since an attribute can hardly be data typed by another attribute. It's not lost with the .NET Xml parser, just made different. The Xml schema has its own namespace and has the equivalent API you referred to, scattered in this namespace. For instance,
System.Xml.Schema.XmlSchemaDatatype.ParseValue()
. PS : the .NET Xml parser is not a wrapper of the MSXML parser, which is a very good design decision. (at least something that stands for itself in this .NET run-time)..S.Rod. wrote: ...(at least something that stands for itself in this .NET run-time). Why Stephane, I haven't noticed your using that "smiley" before. ;) If I didn't know better, I'd say you are among those of us who have been wrestling with the insanity of the software industry for so long... "Few are those who see with their own eyes and feel with their own hearts." - A. Einstein
-
.S.Rod. wrote: ...(at least something that stands for itself in this .NET run-time). Why Stephane, I haven't noticed your using that "smiley" before. ;) If I didn't know better, I'd say you are among those of us who have been wrestling with the insanity of the software industry for so long... "Few are those who see with their own eyes and feel with their own hearts." - A. Einstein
A last funny pic before tonight's hunting,