.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
.    if \nF \{
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "XML::LibXML::Text 3pm"
.TH XML::LibXML::Text 3pm "2013-12-17" "perl v5.18.2" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
XML::LibXML::Text \- XML::LibXML Class for Text Nodes
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 3
\&  use XML::LibXML;
\&  # Only methods specific to Text nodes are listed here,
\&  # see XML::LibXML::Node manpage for other methods
\&
\&  $text = XML::LibXML::Text\->new( $content );
\&  $nodedata = $text\->data;
\&  $text\->setData( $text_content );
\&  $text\->substringData($offset, $length);
\&  $text\->appendData( $somedata );
\&  $text\->insertData($offset, $string);
\&  $text\->deleteData($offset, $length);
\&  $text\->deleteDataString($remstring, $all);
\&  $text\->replaceData($offset, $length, $string);
\&  $text\->replaceDataString($old, $new, $flag);
\&  $text\->replaceDataRegEx( $search_cond, $replace_cond, $reflags );
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Unlike the \s-1DOM\s0 specification, XML::LibXML implements the text node as the base
class of all character data node. Therefore there exists no CharacterData
class. This allows one to apply methods of text nodes also to Comments and
CDATA-sections.
.SH "METHODS"
.IX Header "METHODS"
The class inherits from XML::LibXML::Node. The documentation for Inherited methods is not listed here.
.PP
Many functions listed here are extensively documented in the \s-1DOM\s0 Level 3 specification (<http://www.w3.org/TR/DOM\-Level\-3\-Core/>). Please refer to the specification for extensive documentation.
.IP "new" 4
.IX Item "new"
.Vb 1
\&  $text = XML::LibXML::Text\->new( $content );
.Ve
.Sp
The constructor of the class. It creates an unbound text node.
.IP "data" 4
.IX Item "data"
.Vb 1
\&  $nodedata = $text\->data;
.Ve
.Sp
Although there exists the \f(CW\*(C`nodeValue\*(C'\fR attribute in the Node class, the \s-1DOM\s0 specification defines data as a separate
attribute. \f(CW\*(C`XML::LibXML\*(C'\fR implements these two attributes not as different attributes, but as aliases,
such as \f(CW\*(C`libxml2\*(C'\fR does. Therefore
.Sp
.Vb 1
\&  $text\->data;
.Ve
.Sp
and
.Sp
.Vb 1
\&  $text\->nodeValue;
.Ve
.Sp
will have the same result and are not different entities.
.IP "setData($string)" 4
.IX Item "setData($string)"
.Vb 1
\&  $text\->setData( $text_content );
.Ve
.Sp
This function sets or replaces text content to a node. The node has to be of
the type \*(L"text\*(R", \*(L"cdata\*(R" or \*(L"comment\*(R".
.IP "substringData($offset,$length)" 4
.IX Item "substringData($offset,$length)"
.Vb 1
\&  $text\->substringData($offset, $length);
.Ve
.Sp
Extracts a range of data from the node. (\s-1DOM\s0 Spec) This function takes the two
parameters \f(CW$offset\fR and \f(CW$length\fR and returns the sub-string, if available.
.Sp
If the node contains no data or \f(CW$offset\fR refers to an non-existing string index,
this function will return \fIundef\fR. If \f(CW$length\fR is out of range \f(CW\*(C`substringData\*(C'\fR will return the data starting at \f(CW$offset\fR instead of causing an error.
.IP "appendData($string)" 4
.IX Item "appendData($string)"
.Vb 1
\&  $text\->appendData( $somedata );
.Ve
.Sp
Appends a string to the end of the existing data. If the current text node
contains no data, this function has the same effect as \f(CW\*(C`setData\*(C'\fR.
.IP "insertData($offset,$string)" 4
.IX Item "insertData($offset,$string)"
.Vb 1
\&  $text\->insertData($offset, $string);
.Ve
.Sp
Inserts the parameter \f(CW$string\fR at the given \f(CW$offset\fR of the existing data of the
node. This operation will not remove existing data, but change the order of the
existing data.
.Sp
The \f(CW$offset\fR has to be a positive value. If \f(CW$offset\fR is out of range, \f(CW\*(C`insertData\*(C'\fR will have the same behaviour as \f(CW\*(C`appendData\*(C'\fR.
.ie n .IP "deleteData($offset, $length)" 4
.el .IP "deleteData($offset, \f(CW$length\fR)" 4
.IX Item "deleteData($offset, $length)"
.Vb 1
\&  $text\->deleteData($offset, $length);
.Ve
.Sp
This method removes a chunk from the existing node data at the given offset.
The \f(CW$length\fR parameter tells, how many characters should be removed from the
string.
.IP "deleteDataString($string, [$all])" 4
.IX Item "deleteDataString($string, [$all])"
.Vb 1
\&  $text\->deleteDataString($remstring, $all);
.Ve
.Sp
This method removes a chunk from the existing node data. Since the \s-1DOM\s0 spec is
quite unhandy if you already know \f(CW\*(C`which\*(C'\fR string to remove from a text node, this method allows more perlish code :)
.Sp
The functions takes two parameters: \fI\f(CI$string\fI\fR and optional the \fI\f(CI$all\fI\fR flag. If \f(CW$all\fR is not set, \fIundef\fR or \fI0\fR, \f(CW\*(C`deleteDataString\*(C'\fR will remove only the first occurrence of \f(CW$string\fR. If \f(CW$all\fR is \fI\s-1TRUE\s0\fR\f(CW\*(C`deleteDataString\*(C'\fR will remove all occurrences of \fI\f(CI$string\fI\fR from the node data.
.ie n .IP "replaceData($offset, $length, $string)" 4
.el .IP "replaceData($offset, \f(CW$length\fR, \f(CW$string\fR)" 4
.IX Item "replaceData($offset, $length, $string)"
.Vb 1
\&  $text\->replaceData($offset, $length, $string);
.Ve
.Sp
The \s-1DOM\s0 style version to replace node data.
.ie n .IP "replaceDataString($oldstring, $newstring, [$all])" 4
.el .IP "replaceDataString($oldstring, \f(CW$newstring\fR, [$all])" 4
.IX Item "replaceDataString($oldstring, $newstring, [$all])"
.Vb 1
\&  $text\->replaceDataString($old, $new, $flag);
.Ve
.Sp
The more programmer friendly version of \fIreplaceData()\fR :)
.Sp
Instead of giving offsets and length one can specify the exact string (\fI\f(CI$oldstring\fI\fR) to be replaced. Additionally the \fI\f(CI$all\fI\fR flag allows one to replace all occurrences of \fI\f(CI$oldstring\fI\fR.
.ie n .IP "replaceDataRegEx( $search_cond, $replace_cond, $reflags )" 4
.el .IP "replaceDataRegEx( \f(CW$search_cond\fR, \f(CW$replace_cond\fR, \f(CW$reflags\fR )" 4
.IX Item "replaceDataRegEx( $search_cond, $replace_cond, $reflags )"
.Vb 1
\&  $text\->replaceDataRegEx( $search_cond, $replace_cond, $reflags );
.Ve
.Sp
This method replaces the node's data by a \f(CW\*(C`simple\*(C'\fR regular expression. Optional, this function allows one to pass some flags that
will be added as flag to the replace statement.
.Sp
\&\fI\s-1NOTE:\s0\fR This is a shortcut for
.Sp
.Vb 3
\&  my $datastr = $node\->getData();
\&   $datastr =~ s/somecond/replacement/g; # \*(Aqg\*(Aq is just an example for any flag
\&   $node\->setData( $datastr );
.Ve
.Sp
This function can make things easier to read for simple replacements. For more
complex variants it is recommended to use the code snippet above.
.SH "AUTHORS"
.IX Header "AUTHORS"
Matt Sergeant,
Christian Glahn,
Petr Pajas
.SH "VERSION"
.IX Header "VERSION"
2.0108
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
2001\-2007, AxKit.com Ltd.
.PP
2002\-2006, Christian Glahn.
.PP
2006\-2009, Petr Pajas.
