pugixml.pugi.XMLText
- class pugixml.pugi.XMLText
Bases:
pybind11_objectA helper for working with text inside PCDATA nodes.
Examples
>>> from pugixml import pugi >>> doc = pugi.XMLDocument() >>> doc.load_string('<node/>') >>> node = doc.child('node') >>> a = node.append_child('a').append_child(pugi.NODE_CDATA) >>> a.text().set('foo') >>> b = node.append_child(pugi.NODE_PCDATA) >>> b.text().set('bar') >>> c = node.append_child(pugi.NODE_ELEMENT) >>> c.set_name('c') >>> c.text().set('baz') >>> node.print(pugi.PrintWriter(), indent=' ') <node> <a><![CDATA[foo]]></a>bar<c>baz</c> </node>
Methods
__bool__(self)Determine if this object is not empty.
__init__(self)Initialize
XMLTextas an empty text.as_bool(self[, default])Return the contents as a boolean.
as_double(self[, default])as_float(self[, default])as_int(self[, default])as_llong(self[, default])as_string(self[, default])Return the contents.
as_uint(self[, default])Return the contents as a number [0,
UINT_MAX].as_ullong(self[, default])Return the contents as a number [0,
ULLONG_MAX].data(self)Return the data node (
NODE_PCDATAorNODE_CDATA) for this object.empty(self)Determine if this object is empty.
get(self)Return the contents.
set(*args, **kwargs)Overloaded function.
Member Documentation
- __bool__(self: pugixml.pugi.XMLText) bool
Determine if this object is not empty.
- Returns:
Trueif the object is not empty,Falseotherwise.
- __init__(self: pugixml.pugi.XMLText) None
Initialize
XMLTextas an empty text.
- as_bool(self: pugixml.pugi.XMLText, default: bool = False) bool
Return the contents as a boolean.
- Parameters:
default – The default value.
- Returns:
The contents as a boolean (returns
Trueif first character is in ‘1tTyY’ set), or the default value if the conversion fails or the object is empty.
- as_double(self: pugixml.pugi.XMLText, default: SupportsFloat | SupportsIndex = 0) float
Return the contents as a number [
DBL_MIN,DBL_MAX].- Parameters:
default – The default value.
- Returns:
The contents as a number, or the default value if the conversion fails or the object is empty.
- as_float(self: pugixml.pugi.XMLText, default: SupportsFloat | SupportsIndex = 0) float
Return the contents as a number [
FLT_MIN,FLT_MAX].- Parameters:
default – The default value.
- Returns:
The contents as a number, or the default value if the conversion fails or the object is empty.
- as_int(self: pugixml.pugi.XMLText, default: SupportsInt | SupportsIndex = 0) int
Return the contents as a number [
INT_MIN,INT_MAX].- Parameters:
default – The default value.
- Returns:
The contents as a number, or the default value if the conversion fails or the object is empty.
- as_llong(self: pugixml.pugi.XMLText, default: SupportsInt | SupportsIndex = 0) int
Return the contents as a number [
LLONG_MIN,LLONG_MAX].- Parameters:
default – The default value.
- Returns:
The contents as a number, or the default value if the conversion fails or the object is empty.
- as_string(self: pugixml.pugi.XMLText, default: str = '') str
Return the contents.
- Parameters:
default – The default value.
- Returns:
The contents, or the default value if the object is empty.
- as_uint(self: pugixml.pugi.XMLText, default: SupportsInt | SupportsIndex = 0) int
Return the contents as a number [0,
UINT_MAX].- Parameters:
default – The default value.
- Returns:
The contents as a number, or the default value if the conversion fails or the object is empty.
- as_ullong(self: pugixml.pugi.XMLText, default: SupportsInt | SupportsIndex = 0) int
Return the contents as a number [0,
ULLONG_MAX].- Parameters:
default – The default value.
- Returns:
The contents as a number, or the default value if the conversion fails or the object is empty.
- data(self: pugixml.pugi.XMLText) pugixml.pugi.XMLNode
Return the data node (
NODE_PCDATAorNODE_CDATA) for this object.- Returns:
The data node for this object.
- empty(self: pugixml.pugi.XMLText) bool
Determine if this object is empty.
- Returns:
Trueif the object is empty,Falseotherwise.
- get(self: pugixml.pugi.XMLText) str
Return the contents.
- Returns:
The contents, or an empty string if the object is empty.
See also
- set(*args, **kwargs)
Overloaded function.
set(self: pugixml.pugi.XMLText, value: str) -> bool
Set the contents.
set(self: pugixml.pugi.XMLText, value: str, size: typing.SupportsInt | typing.SupportsIndex) -> bool
Set the contents with the specified length.
set(self: pugixml.pugi.XMLText, value: bool) -> bool
Set the contents as a boolean (true or false).
set(self: pugixml.pugi.XMLText, value: float) -> bool
set(self: pugixml.pugi.XMLText, value: typing.SupportsFloat | typing.SupportsIndex, precision: typing.SupportsInt | typing.SupportsIndex) -> bool
set(self: pugixml.pugi.XMLText, value: typing.SupportsInt | typing.SupportsIndex) -> bool
set(self: pugixml.pugi.XMLText, value: typing.SupportsInt | typing.SupportsIndex) -> bool
Set the contents as a number [0,
ULLONG_MAX].
- Parameters:
value – The contents to set.
size – The length of the contents as a string.
precision – The precision of the contents as a floating point number.
- Returns:
Falseif the object is empty or there is not enough memory.