Return contents (with text nodes): >>> d = PyQuery('hello bold ') >>> d.contents() # doctest: +ELLIPSIS ['hello ', ]
(self)
| 576 | return self._copy(result, parent=self) |
| 577 | |
| 578 | def contents(self): |
| 579 | """ |
| 580 | Return contents (with text nodes): |
| 581 | |
| 582 | >>> d = PyQuery('hello <b>bold</b>') |
| 583 | >>> d.contents() # doctest: +ELLIPSIS |
| 584 | ['hello ', <Element b at ...>] |
| 585 | """ |
| 586 | results = [] |
| 587 | for elem in self: |
| 588 | results.extend(elem.xpath('child::text()|child::*', |
| 589 | namespaces=self.namespaces)) |
| 590 | return self._copy(results, parent=self) |
| 591 | |
| 592 | def filter(self, selector): |
| 593 | """Filter elements in self using selector (string or function): |