-
Accessing the datatype member from DOMs Node object
I am having trouble accessing the datatype of an element in my xml document.
Is there anything specific I need to do to enable the datatype attribute
of the DOM node object to pick up the datatype defined in my schema ( xsd
file) .
I have a little bell ringing in my head telling me that is can only be done
using XDR definitions but this can be right can it?
The vb test code I'm using is below but I'm implementing this is C++.
VB Code.....
Set xmldoc = New MSXML2.DOMDocument40
xmldoc.async = False
xmldoc.validateOnParse = True
Dim schemaCache As MSXML2.XMLSchemaCache40
Set schemaCache = New MSXML2.XMLSchemaCache40
schemaCache.Add "", "D:\Projects\CRMFriendly\schema\CustomerUpdate.xsd"
Set xmldoc.schemas = schemaCache
'Load XML document
xmldoc.Load "D:\Projects\CRMFriendly\xml\CustomerUpdate.xml"
xmldoc.Validate
Set aNode = xmldoc.documentElement.firstChild
Dim vTemp, vVariant As Variant
If aNode.childNodes.Item(1).baseName = "number" Then
vTemp = aNode.childNodes.Item(1).nodeTypedValue
vVariant = aNode.childNodes.Item(1).dataType
End if
I have viewed the node object in the watch window and all the members seem
populated correctly apart from the datatype which is always NULL.
Is ther anything I should specifically define in my XML/XSD documents or
even set in the DOMDocument object??
Thanks
-
Re: Accessing the datatype member from DOMs Node object
This can be done using the new MSXML 4.0 SDK from Microsoft.
It has something call SOM the schema object model which when used with DOM
can retreive the datatypes from a XSD file.
There is an example in VB on the microsoft web site.
have a look at Q309616.
Thanks
Ricky ( Richards Alter ego!)
"Richard" <Richard.Frame@telesensKSCL.com> wrote:
>
>I am having trouble accessing the datatype of an element in my xml document.
>
>Is there anything specific I need to do to enable the datatype attribute
>of the DOM node object to pick up the datatype defined in my schema ( xsd
>file) .
>I have a little bell ringing in my head telling me that is can only be done
>using XDR definitions but this can be right can it?
>
>The vb test code I'm using is below but I'm implementing this is C++.
>
>VB Code.....
>
> Set xmldoc = New MSXML2.DOMDocument40
>
> xmldoc.async = False
> xmldoc.validateOnParse = True
>
> Dim schemaCache As MSXML2.XMLSchemaCache40
> Set schemaCache = New MSXML2.XMLSchemaCache40
>
> schemaCache.Add "", "D:\Projects\CRMFriendly\schema\CustomerUpdate.xsd"
> Set xmldoc.schemas = schemaCache
>
> 'Load XML document
> xmldoc.Load "D:\Projects\CRMFriendly\xml\CustomerUpdate.xml"
> xmldoc.Validate
>
> Set aNode = xmldoc.documentElement.firstChild
> Dim vTemp, vVariant As Variant
>
> If aNode.childNodes.Item(1).baseName = "number" Then
> vTemp = aNode.childNodes.Item(1).nodeTypedValue
> vVariant = aNode.childNodes.Item(1).dataType
> End if
>
>
>I have viewed the node object in the watch window and all the members seem
>populated correctly apart from the datatype which is always NULL.
>
>Is ther anything I should specifically define in my XML/XSD documents or
>even set in the DOMDocument object??
>
>Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks