Remove all namespaces: >>> doc = PyQuery(' ') >>> doc [<{http://example.com/foo}foo>] >>> doc.remove_namespaces() [ ]
(self)
| 326 | return self |
| 327 | |
| 328 | def remove_namespaces(self): |
| 329 | """Remove all namespaces: |
| 330 | |
| 331 | >>> doc = PyQuery('<foo xmlns="http://example.com/foo"></foo>') |
| 332 | >>> doc |
| 333 | [<{http://example.com/foo}foo>] |
| 334 | >>> doc.remove_namespaces() |
| 335 | [<foo>] |
| 336 | """ |
| 337 | try: |
| 338 | root = self[0].getroottree() |
| 339 | except IndexError: |
| 340 | pass |
| 341 | else: |
| 342 | for el in root.iter('{*}*'): |
| 343 | if el.tag.startswith('{'): |
| 344 | el.tag = el.tag.split('}', 1)[1] |
| 345 | return self |
| 346 | |
| 347 | def __str__(self): |
| 348 | """xml representation of current nodes:: |
no outgoing calls