scans through all children of node and gathers the text. if node has non-text child-nodes, then NotTextNodeError is raised.
(node)
| 15 | |
| 16 | |
| 17 | def getTextFromNode(node): |
| 18 | """ |
| 19 | scans through all children of node and gathers the |
| 20 | text. if node has non-text child-nodes, then |
| 21 | NotTextNodeError is raised. |
| 22 | """ |
| 23 | t = "" |
| 24 | for n in node.childNodes: |
| 25 | if n.nodeType == n.TEXT_NODE: |
| 26 | t += n.nodeValue |
| 27 | else: |
| 28 | raise NotTextNodeError |
| 29 | return t |
| 30 | |
| 31 | |
| 32 | def nodeToDic(node): |