Lines Matching defs:text
22 'text' - a string containing the element's text content.
24 'tail' - an optional string containing text after the element's end tag.
132 its length AND its text attribute.
142 <tag attrib>text<child/>...</tag>tail
152 text = None
155 Note that if there is no text, this attribute may be either
164 was no text, this attribute may be either None or an empty string,
206 elem.text = self.text
240 subelement (or directly after the text, if it's the first subelement),
295 """Find text for first matching element by tag name or path.
301 Return text content of first matching element, or default value if
302 none was found. Note that if an element is found having no text
334 the text and tail attributes to None.
339 self.text = self.tail = None
407 """Create text iterator.
410 order, returning all inner text.
416 t = self.text
444 def Comment(text=None):
450 *text* is a string containing the comment string.
454 element.text = text
458 def ProcessingInstruction(target, text=None):
464 *target* is a string containing the processing instruction, *text* is a
469 element.text = target
470 if text:
471 element.text = element.text + " " + text
494 self.text = text_or_uri
496 return self.text
498 return '<%s %r>' % (self.__class__.__name__, self.text)
500 return hash(self.text)
503 return self.text <= other.text
504 return self.text <= other
507 return self.text < other.text
508 return self.text < other
511 return self.text >= other.text
512 return self.text >= other
515 return self.text > other.text
516 return self.text > other
519 return self.text == other.text
520 return self.text == other
713 *method* -- either "xml" (default), "html, "text", or "c14n"
738 if method == "text":
755 # returns text write method and release all resources after using
767 # encoding determines if it is a text or binary writer
769 # use a text writer as is
845 if tag.text not in qnames:
846 add_qname(tag.text)
854 key = key.text
857 if isinstance(value, QName) and value.text not in qnames:
858 add_qname(value.text)
859 text = elem.text
860 if isinstance(text, QName) and text.text not in qnames:
861 add_qname(text.text)
867 text = elem.text
869 write("<!--%s-->" % text)
871 write("<?%s?>" % text)
875 if text:
876 write(_escape_cdata(text))
895 k = k.text
897 v = qnames[v.text]
901 if text or len(elem) or not short_empty_elements:
903 if text:
904 write(_escape_cdata(text))
920 text = elem.text
922 write("<!--%s-->" % _escape_cdata(text))
924 write("<?%s?>" % _escape_cdata(text))
928 if text:
929 write(_escape_cdata(text))
947 k = k.text
949 v = qnames[v.text]
956 if text:
958 write(text)
960 write(_escape_cdata(text))
977 "text": _serialize_text,
1017 def _raise_serialization_error(text):
1019 "cannot serialize %r (type %s)" % (text, type(text).__name__)
1022 def _escape_cdata(text):
1028 if "&" in text:
1029 text = text.replace("&", "&")
1030 if "<" in text:
1031 text = text.replace("<", "<")
1032 if ">" in text:
1033 text = text.replace(">", ">")
1034 return text
1036 _raise_serialization_error(text)
1038 def _escape_attrib(text):
1041 if "&" in text:
1042 text = text.replace("&", "&")
1043 if "<" in text:
1044 text = text.replace("<", "<")
1045 if ">" in text:
1046 text = text.replace(">", ">")
1047 if "\"" in text:
1048 text = text.replace("\"", """)
1056 if "\r" in text:
1057 text = text.replace("\r", " ")
1058 if "\n" in text:
1059 text = text.replace("\n", " ")
1060 if "\t" in text:
1061 text = text.replace("\t", "	")
1062 return text
1064 _raise_serialization_error(text)
1066 def _escape_attrib_html(text):
1069 if "&" in text:
1070 text = text.replace("&", "&")
1071 if ">" in text:
1072 text = text.replace(">", ">")
1073 if "\"" in text:
1074 text = text.replace("\"", """)
1075 return text
1077 _raise_serialization_error(text)
1091 be one of "xml" (default), "html", "text" or "c14n", *default_namespace*
1159 itself will not be changed, but the tail text of all elements in its
1188 if not elem.text or not elem.text.strip():
1189 elem.text = child_indentation
1325 def XML(text, parser=None):
1330 *text* is a string containing XML data, *parser* is an
1338 parser.feed(text)
1342 def XMLID(text, parser=None):
1345 *text* is a string containing XML data, *parser* is an
1354 parser.feed(text)
1377 for text in sequence:
1378 parser.feed(text)
1433 text = "".join(self._data)
1436 self._last.tail = text
1438 assert self._last.text is None, "internal error (text)"
1439 self._last.text = text
1443 """Add text to current element."""
1477 def comment(self, text):
1480 *text* is the text of the comment.
1483 self._comment_factory, self.insert_comments, text)
1485 def pi(self, target, text=None):
1489 *text* is the data of the processing instruction, or ''.
1492 self._pi_factory, self.insert_pis, target, text)
1603 def handler(text, event=event_name, append=append, self=self):
1604 append((event, self.target.comment(text)))
1652 def _default(self, text):
1653 prefix = text[:1]
1661 data_handler(self.entity[text[1:-1]])
1666 (text, self.parser.ErrorLineNumber,
1673 elif prefix == "<" and text[:9] == "<!DOCTYPE":
1680 text = text.strip()
1681 if not text:
1683 self._doctype.append(text)
1738 the serialised canonical XML output (text, not bytes) through its ``.write()``
1739 method. To write to a file, open it in text mode with encoding "utf-8".
1740 If *out* is not provided, this function returns the output as text string.
1774 as text (not bytes). To write to a file, open it in text mode with encoding
1780 - *strip_text*: set to true to strip whitespace before and after text content
1783 should be replaced in text content
1785 should be replaced in text content
1896 # we may have to resolve qnames in text content
1913 # Need to parse text first to see if it requires a prefix declaration.
1925 # Resolve prefixes in attribute and tag text.
1980 # Write the resolved qname text content.
1999 def comment(self, text):
2008 self._write(f'<!--{_escape_cdata_c14n(text)}-->')
2025 def _escape_cdata_c14n(text):
2031 if '&' in text:
2032 text = text.replace('&', '&')
2033 if '<' in text:
2034 text = text.replace('<', '<')
2035 if '>' in text:
2036 text = text.replace('>', '>')
2037 if '\r' in text:
2038 text = text.replace('\r', '
')
2039 return text
2041 _raise_serialization_error(text)
2044 def _escape_attrib_c14n(text):
2047 if '&' in text:
2048 text = text.replace('&', '&')
2049 if '<' in text:
2050 text = text.replace('<', '<')
2051 if '"' in text:
2052 text = text.replace('"', '"')
2053 if '\t' in text:
2054 text = text.replace('\t', '	')
2055 if '\n' in text:
2056 text = text.replace('\n', '
')
2057 if '\r' in text:
2058 text = text.replace('\r', '
')
2059 return text
2061 _raise_serialization_error(text)