Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

dataType Property [DOM]

Specifies the data type for this element or attribute. When a DTD is used, the dataType property is only applicable to attributes, in which case dataType returns the attribute-type according to the DTD. The value returned will use XDR naming conventions, however. In other words, the type is returned in lower-case. This is different from the DTD convention. When using XDR, or when an element has a dt:dt attribute, elements may also have datatypes.

MSXML 6.0 does not support XDR schemas. However, elements can have an XDR data type by having a dt:dt attribute. For more information, see Removal of XDR Schema Support.

This method does not support elements or attributes that have data types defined by XSD schemas. If the document uses an XSD schema, this method returns null.

objValue = oXMLDOMNode.dataType;
objXMLDOMNode.dataType = objValue;

Example

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmlDoc.async = false;
xmlDoc.loadXML("<root/>");
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   var root = xmlDoc.documentElement;
   root.dataType = "int";
   root.nodeTypedValue = 5;
   WScript.Echo(xmlDoc.xml);
}


objValue = oXMLDOMNode.dataType
objXMLDOMNode.dataType = objValue

HRESULT get_dataType(
    VARIANT *dataTypeName);
HRESULT put_dataType(
    BSTR dataTypeName);

dataTypeName[out, retval][in]

The VARIANT can be a BSTR that contains the data type name, or VT_NULL if no data type is defined.

S_OK

The value returned if successful.

S_FALSE (for get_dataTypeonly)

The value returned if the node is not typed.

E_INVALIDARG (for get_dataTypeonly)

The value returned if the dataTypeName parameter is Null.

E_FAIL (for put_dataTypeonly)

The value returned if an error occurs.

The property is read/write. The VARIANT can be a BSTR that contains the data type name, or VT_NULL if no data type is defined. This property applies to DTDs only, not to XML-Data Reduced (XDR) schemas or XML Schemas (XSD). This value depends on the value of the nodeType property of the IXMLDOMNode.

This member is an extension of the World Wide Web Consortium (W3C) Document Object Model (DOM).

NODE_ATTRIBUTE

Contains the string representation of the data type specifier included in the schema, or Null if no data type is specified.

NODE_CDATA_SECTION

NODE_COMMENT NODE_DOCUMENT

NODE_DOCUMENT_FRAGMENT

NODE_DOCUMENT_TYPE

NODE_ENTITY

NODE_NOTATION

NODE_PROCESSING_INSTRUCTION

NODE_TEXT

Contains the constant string value "string". These node types do not have data types, so the dataType property cannot be set for these node types. Attempts to set this property are ignored.

NODE_ELEMENT

Contains the string representation of the data type specifier included on the instance of the element or in the schema, or Null if no data type is specified.

NODE_ENTITY_REFERENCE

Contains the string representation of the data type specifier for the referenced entity. This is limited to entities with a single data type on the root level element of the subtree corresponding to the entity. Contains Null if no data type is specified. It is not possible to set the data type of an entity reference. The data type must be set directly on the referenced element. Attempts to set the value of the dataType property are ignored.

Implemented in:

MSXML 3.0, MSXML 6.0

Show:
© 2014 Microsoft