Click to return to the XML (Extensible Markup Language) home page    
XMLDOMNode specified Prop...     XMLDOMNode transformNode ...     XMLDOMNode Object    
Web Workshop  |  XML (Extensible Markup Language)

text Property


Contains the text content of the node and its subtrees.

Syntax

strValue = oXMLDOMNode.text
objXMLDOMNode.text = strValue

Remarks

String. The property is read/write. It returns the string representing the text contents of this node or the concatenated text representing this node and its descendants. When concatenated, the text represents the contents of text or CDATA nodes. All concatenated text nodes are normalized according to xml:space attributes and the value of the preserveWhitespace switch. Concatenated CDATA text is not normalized. (Child nodes that contain NODE_COMMENT and NODE_PROCESSING_INSTRUCTION nodes are not concatenated.)

Consider the "root" element in this example:

<root att="   123   a   <   ">
   <a>   a   a   </a>
   <!--   comment   b   -->
   <?pi   pi   c   ?>
   <![CDATA[   cdata   d   ]]>
   e   f
</root>

The text property for the root element returns the concatenated text:

"a a   cdata   d    e f"

Note that the white space within the CDATA node is preserved.

This value depends on the value of the nodeType property.

NODE_ATTRIBUTE,
NODE_DOCUMENT,
NODE_ENTITY
Returns a string representing the value of the node. This is the concatenated text of all subnodes with entities expanded.
NODE_CDATA_SECTION,
NODE_COMMENT,
NODE_PROCESSING_INSTRUCTION,
NODE_TEXT
Returns the text contained in the node, which is the same as the nodeValue property.
NODE_DOCUMENT_TYPE,
NODE_NOTATION
Returns the empty string (""). These node types do not have associated text.
NODE_DOCUMENT_FRAGMENT
Returns the text comprised of the concatenation of all descendant nodes.
NODE_ELEMENT
Contains a string that represents the element content. Note that this will also include the text content from all child elements, concatenated in document order. For example, consider the following XML:
<count>
  <item>one</item>
  <item>two</item>
  <item>three</item>
  <item>four</item>
</count>

The text property for the "count" element contains the value "one two three four".

NODE_ENTITY_REFERENCE
Returns the string representation of the entity reference.

This member is an extension of the W3C DOM.

Example

The following example creates an XMLDOMNode object (of type NODE_ENTITY), then displays the object's text value (including that of any of the object's child nodes):

Dim xmlDoc
Dim currNode

Set xmlDoc = CreateObject("microsoft.xmldom")
xmlDoc.async = False
xmlDoc.load("c:\books.xml")
Set currNode = xmlDoc.documentElement.childNodes.item(0)
MsgBox currNode.text

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
XMLDOMAttribute, XMLDOMCDATASection, XMLDOMCharacterData, XMLDOMComment, XMLDOMDocument, XMLDOMDocumentFragment, XMLDOMDocumentType, XMLDOMElement, XMLDOMEntity, XMLDOMEntityReference, XMLDOMNode, XMLDOMNotation, XMLDOMProcessingInstruction, XMLDOMText, XTLRuntime

See Also

White space handling


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.