Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - DOM Reference

specified Property

Indicates whether the node (usually an attribute) is explicitly specified or derived from a default value in the document type definition (DTD) or schema.

[Script]

Script Syntax

boolValue = oXMLDOMNode.specified;

Example

The following script example creates an IXMLDOMNode from the specified item in an IXMLDOMNamedNodeMap. It then displays whether or not the attribute was specified in the element, rather than in a DTD or schema.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");
var currNode;
var objNamedNodeMap;
var myNode;
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode <> 0) {
   var myErr = xmlDoc.parseError;
   alert("You have error " + myErr.reason);
} else {
   currNode = xmlDoc.documentElement.childNodes.item(0);
   objNamedNodeMap = currNode.attributes;
   myNode = objNamedNodeMap.item(0);
   alert(myNode.specified);
}
[Visual Basic]

Visual Basic Syntax

boolValue = oXMLDOMNode.specified

Example

The following Microsoft® Visual Basic® example creates an IXMLDOMNode from the specified item in an IXMLDOMNamedNodeMap. It then displays whether or not the attribute was specified in the element, rather than in a DTD or schema.

Dim xmlDoc As New Msxml2.DOMDocument50
Dim currNode As IXMLDOMNode
Dim objNamedNodeMap As IXMLDOMNamedNodeMap
Dim myNode As IXMLDOMNode
xmlDoc.async = False
xmlDoc.Load ("books.xml")
If (xmlDoc.parseError.errorCode <> 0) Then
   Dim myErr
   Set myErr = xmlDoc.parseError
   MsgBox("You have error " & myErr.reason)
Else
   Set currNode = xmlDoc.documentElement.childNodes.Item(0)
   Set objNamedNodeMap = currNode.Attributes
   Set myNode = objNamedNodeMap.Item(0)
   MsgBox myNode.specified
End If
[C/C++]

C/C++ Syntax

HRESULT get_specified(
    VARIANT_BOOL *isSpecified);

Parameters

isSpecified [out, retval]
True if the attribute is explicitly specified in the element; False if the attribute value comes from the DTD or schema.

C/C++ Return Values

S_OK
The value returned if successful.
E_INVALIDARG
The value returned if the isSpecified parameter is Null.

Remarks

Boolean. The property is read-only. Returns True if the attribute is explicitly specified in the element. Returns False if the attribute value comes from the DTD or schema.

This value depends on the value of the nodeType property.

NODE_ATTRIBUTE Returns True if the attribute was specified directly on the element. Returns False for default attributes.
NODE_CDATA_SECTION

NODE_COMMENT

NODE_DOCUMENT

NODE_DOCUMENT_FRAGMENT

NODE_DOCUMENT_TYPE

NODE_ELEMENT

NODE_ENTITY

NODE_ENTITY_REFERENCE

NODE_NOTATION

NODE_PROCESSING_INSTRUCTION

NODE_TEXT

Returns True.

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

To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

nodeType Property

Applies to: IXMLDOMAttribute | IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | DOMDocument | IXMLDOMDocumentFragment | IXMLDOMDocumentType | IXMLDOMElement | IXMLDOMEntity | IXMLDOMEntityReference | IXMLDOMNode | IXMLDOMNotation | IXMLDOMProcessingInstruction | IXMLDOMText