Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

Represents the text content of the node or the concatenated text representing the node and its descendants.

Script Syntax

Copy Code
		
strValue = oXMLDOMNode.text;

Remarks

Script Parameters

None.

Script Return Value

String. String representing the text content of this node and its descendants. This value varies depending on the value of the nodeTypeproperty.

C/C++ Syntax

Copy Code
HRESULT get_text(
  BSTR* 
text
);

Remarks

C/C++ Parameters

text

[out, retval] String representing the text content of this node and its descendants. This value varies depending on the value of the nodeTypeproperty.

C/C++ Return Values

S_OK

Value returned if successful.

S_FALSE

Value returned when there is no text.

E_INVALIDARG

Value returned if textis Null.

Requirements

Header msxml2.h, msxml2.idl
Windows Embedded CE Windows CE .NET 4.0 and later

General Remarks

When concatenated, the text represents the contents of text or CDATA nodes. All concatenated text nodes are normalized according to xml:spaceattributes and the value of the preserveWhiteSpaceswitch. Concatenated CDATA text is not normalized. (Child nodes that contain NODE_COMMENT and NODE_PROCESSING_INSTRUCTION nodes are not concatenated.)

Retrieves and sets the string representing the text contents of this node or the concatenated text representing this node and its descendants.

For more precise control over text manipulation in an XML document, use the lower-level nodeValueproperty, which returns the raw text associated with a NODE_TEXT node.

Consider the "root" element in this example.

Copy Code
<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 following concatenated text.

Copy Code
"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 nodeTypeproperty.

Value Description

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 nodeValueproperty.

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:

Copy Code
<count>
  <item>one</item>
  <item>two</item>
  <item>three</item>
  <item>four</item>
</count>

The textproperty for the <count> element contains the value "one two three four".

NODE_ENTITY_REFERENCE

Returns the string representation of the entity reference.

This property is read/write, and applies to the following objects and interfaces:

IXMLDOMAttribute, IXMLDOMCDATASection, IXMLDOMCharacterData, IXMLDOMComment, DOMDocument, IXMLDOMDocumentFragment, IXMLDOMDocumentType, IXMLDOMElement, IXMLDOMEntity, IXMLDOMEntityReference, IXMLDOMNode, IXMLDOMNotation, IXMLDOMProcessingInstruction, IXMLDOMText, and IXTLRuntime.

See Also