This property is a Microsoft extension to the W3C DOM.
Object Attr CDATASection
CharacterData Comment Document DocumentFragment
DocumentType Entity EntityReference Node
Notation ProcessingInstruction Text
Object.text
The text property contains the text content of this node and its subtrees. Where the
node has a subtree, text content from it is concatenated to that of the main node into one
string. When concatenated, the text represents the content of text and CDATA nodes. All
concatenated text nodes are normalized according to xml:space attributes and the
value of the preserveWhiteSpace property.
Concatenated CDATA text is not normalized. (Child nodes containing
Comment or
ProcessingInstruction nodes are not concatenated.)
The value returned by the text property depends on the
nodeValue property.
NodeType |
Comments |
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, as these node types do not have associated text.
|
NODE_DOCUMENT_FRAGMENT
|
Returns text comprising the concatenation of descendant nodes.
|
NODE_ELEMENT
|
Returns a string representing the contents of the element, including the text
from all child elements concatenated in document order.
|
NODE_ENTITY_REFERENCE
|
Returns a string representation of the entity reference.
|
In the following example the 'albums.xml' file is loaded, and the text of the last 'Album'
element is displayed.
XML:
<Albums>
<Album ref="CD720">
<category>Pop</category>
<title>Come On Over</title>
<artist>Shania Twain</artist>
</Album>
<Album ref="CD024">
<category>Country</category>
<title>Red Dirt Girl</title>
<artist>Emmylou Harris</artist>
</Album>
</Albums>
Code (VBScript):
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("albums.xml")
Set Album = objXMLDoc.documentElement.lastChild
document.write(Album.text)
Output:
Country Red Dirt Girl Emmylou Harris
|