Accessing the datatype member from DOMs Node object


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Accessing the datatype member from DOMs Node object

  1. #1
    Richard Guest

    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

  2. #2
    Ricky Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center