1XML::DOM::Text(3) User Contributed Perl Documentation XML::DOM::Text(3)
2
3
4
6 XML::DOM::Text - A piece of XML text in XML::DOM
7
9 XML::DOM::Text extends XML::DOM::CharacterData, which extends
10 XML::DOM::Node.
11
12 The Text interface represents the textual content (termed character
13 data in XML) of an Element or Attr. If there is no markup inside an
14 element's content, the text is contained in a single object
15 implementing the Text interface that is the only child of the element.
16 If there is markup, it is parsed into a list of elements and Text nodes
17 that form the list of children of the element.
18
19 When a document is first made available via the DOM, there is only one
20 Text node for each block of text. Users may create adjacent Text nodes
21 that represent the contents of a given element without any intervening
22 markup, but should be aware that there is no way to represent the
23 separations between these nodes in XML or HTML, so they will not (in
24 general) persist between DOM editing sessions. The normalize() method
25 on Element merges any such adjacent Text objects into a single node for
26 each block of text; this is recommended before employing operations
27 that depend on a particular document structure, such as navigation with
28 XPointers.
29
30 METHODS
31 splitText (offset)
32 Breaks this Text node into two Text nodes at the specified offset,
33 keeping both in the tree as siblings. This node then only contains
34 all the content up to the offset point. And a new Text node, which
35 is inserted as the next sibling of this node, contains all the
36 content at and after the offset point.
37
38 Parameters:
39 offset The offset at which to split, starting from 0.
40
41 Return Value: The new Text node.
42
43 DOMExceptions:
44
45 • INDEX_SIZE_ERR
46
47 Raised if the specified offset is negative or greater than the
48 number of characters in data.
49
50 • NO_MODIFICATION_ALLOWED_ERR
51
52 Raised if this node is readonly.
53
54
55
56perl v5.36.0 2023-01-20 XML::DOM::Text(3)