Writes datachars to writer.
(writer, text, attr)
| 294 | |
| 295 | |
| 296 | def _write_data(writer, text, attr): |
| 297 | "Writes datachars to writer." |
| 298 | if not text: |
| 299 | return |
| 300 | # See the comments in ElementTree.py for behavior and |
| 301 | # implementation details. |
| 302 | if "&" in text: |
| 303 | text = text.replace("&", "&") |
| 304 | if "<" in text: |
| 305 | text = text.replace("<", "<") |
| 306 | if ">" in text: |
| 307 | text = text.replace(">", ">") |
| 308 | if attr: |
| 309 | if '"' in text: |
| 310 | text = text.replace('"', """) |
| 311 | if "\r" in text: |
| 312 | text = text.replace("\r", " ") |
| 313 | if "\n" in text: |
| 314 | text = text.replace("\n", " ") |
| 315 | if "\t" in text: |
| 316 | text = text.replace("\t", "	") |
| 317 | writer.write(text) |
| 318 | |
| 319 | def _get_elements_by_tagName_helper(parent, name, rc): |
| 320 | for node in parent.childNodes: |