Click or drag to resize

INodeTextContent Property

Gets or sets the text content of the node and its descendants.

Namespace:  DotNetBrowser.Dom
Assembly:  DotNetBrowser (in DotNetBrowser.dll) Version: 2.22.0
Syntax
C#
string TextContent { get; set; }

Property Value

Type: String
Exceptions
ExceptionCondition
ArgumentExceptionThe value is null.
ObjectDisposedExceptionThe INode has already been disposed.
Remarks

Setting this property on a node removes all of its children and replaces them with a single text node with the given value.

The property value depends on the type of the node, whhich can be checked via the Type property.

The property value is an empty string if the element is a document, a document type, or a notation.

If the node is a CDATA section, a comment, a processing instruction, or a text node, this method returns the text inside this node (the NodeValue).

For other node types, this method returns the concatenation of the TextContent attribute value of every child node, excluding comments and processing instruction nodes. This is an empty string if the node has no children.

Differences from InnerText:

  • The TextContent property gets the content of all elements, including <script> and <style > elements, and the mostly equivalent InnerText property does not.
  • InnerText is also aware of style and will not return the text of hidden elements, whereas TextContent will.
  • As InnerText is aware of CSS styling, it will trigger a reflow, whereas TextContent will not.

See Also