The XMLDOMText Object

The XMLDOMText Object

The XMLDOMText object holds the text content of an element or attribute. If there is no markup inside an element but there is text, that element will contain only one node: a text node that holds the text. (In mixed-content models, text nodes can have sibling element nodes.)

When a document is first made available to the XML DOM, all text is normalized, which means that there is only one text node for each block of text. You can actually create text nodes that are adjacent to each other, although they will not be saved as distinct the next time the document is opened. (It's worth noting that the normalize method on the XMLDOMElement object merges adjacent text nodes into single nodes.)

Here are the base properties of the XMLDOMText object:

  • attributes The list of attributes for this node. Read-only.

  • baseName * The base name for the name qualified with the namespace. Read-only.

  • childNodes A node list containing the child nodes. Read-only.

  • data This node's data (what's actually stored depends on the node type). Read/write.

  • dataType * The data type for this node. Read/write.

  • definition * The definition of the node in the DTD or schema. Read-only.

  • firstChild The first child of the current node. Read-only.

  • lastChild The last child of the current node. Read-only.

  • length The length, in characters , of the data. Read-only.

  • namespaceURI * The URI for the namespace. Read-only.

  • nextSibling The next sibling of this node. Read-only.

  • nodeName The qualified name of an element, attribute, or entity reference, or a string for other node types. Read-only.

  • nodeType The XML DOM node type. Read-only.

  • nodeTypedValue * This node's value. Read/write.

  • nodeTypeString * The node type in string form. Read-only.

  • nodeValue The text associated with the node. Read/write.

  • ownerDocument The root of the document. Read-only.

  • parentNode The parent node. Read-only.

  • parsed * True if this node and all descendants have been parsed; false otherwise . Read-only.

  • prefix * The namespace prefix. Read-only.

  • previousSibling The previous sibling of this node. Read-only.

  • specified Indication of whether the node is explicitly specified or derived from a default value. Read-only.

  • text * The text content of the node and its subtrees. Read/write.

  • xml * The XML representation of the node and all its descendants. Read-only.

Here are the methods of the XMLDOMText object:

  • appendChild Appends a new child as the last child of this node

  • appendData Appends the given string to the existing string data

  • cloneNode Returns a new node that is a copy of this node

  • deleteData Removes the given substring within the string data

  • hasChildNodes Is true if this node has children

  • insertBefore Inserts a child node before the specified node

  • insertData Inserts the supplied string at the specified offset

  • removeChild Removes the specified child node from the list of children

  • replaceChild Replaces the specified child node with the given new child node

  • selectNodes * Replaces the given number of characters with the given string

  • selectSingleNode * Applies the given pattern-matching operation to this node's context, returning a list of matching nodes

  • specified * Applies the specified pattern-matching operation to this node's context, returning an object

  • splitText Breaks this text node into two text nodes

  • substringData Returns a substring of the full string

  • transformNode * Transforms this node and its children using the given XSL stylesheet

  • transformNodeToObject * Transforms this node and its children using the given XSL stylesheet, and returns the resulting transformation as an object

This object does not support any events.

That gives us an overview of the most commonly used objects in the Microsoft XML DOM, and I'm going to put them to work in the rest of the chapter. I'll start at the beginning: loading an XML document.



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net