共用方式為


IText.ReplaceWholeText(String) Method

Definition

Replaces the text of the current node and all logically-adjacent text nodes with the specified text.

[Android.Runtime.Register("replaceWholeText", "(Ljava/lang/String;)Lorg/w3c/dom/Text;", "GetReplaceWholeText_Ljava_lang_String_Handler:Org.W3c.Dom.ITextInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public Org.W3c.Dom.IText? ReplaceWholeText (string? content);
[<Android.Runtime.Register("replaceWholeText", "(Ljava/lang/String;)Lorg/w3c/dom/Text;", "GetReplaceWholeText_Ljava_lang_String_Handler:Org.W3c.Dom.ITextInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member ReplaceWholeText : string -> Org.W3c.Dom.IText

Parameters

content
String

The content of the replacing Text node.

Returns

The Text node created with the specified content.

Attributes

Exceptions

NO_MODIFICATION_ALLOWED_ERR: Raised if one of the Text nodes being replaced is readonly.

Remarks

Replaces the text of the current node and all logically-adjacent text nodes with the specified text. All logically-adjacent text nodes are removed including the current node unless it was the recipient of the replacement text. <br>This method returns the node which received the replacement text. The returned node is: <ul> <li>null, when the replacement text is the empty string; </li> <li>the current node, except when the current node is read-only; </li> <li> a new Text node of the same type ( Text or CDATASection) as the current node inserted at the location of the replacement. </li> </ul> <br>For instance, in the above example calling replaceWholeText on the Text node that contains "bar" with "yo" in argument results in the following: <br>Where the nodes to be removed are read-only descendants of an EntityReference, the EntityReference must be removed instead of the read-only nodes. If any EntityReference to be removed has descendants that are not EntityReference, Text, or CDATASection nodes, the replaceWholeText method must fail before performing any modification of the document, raising a DOMException with the code NO_MODIFICATION_ALLOWED_ERR. <br>For instance, in the example below calling replaceWholeText on the Text node that contains "bar" fails, because the EntityReference node "ent" contains an Element node which cannot be removed.

Added in DOM Level 3.

Java documentation for org.w3c.dom.Text.replaceWholeText(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to