File: domutils.py

package info (click to toggle)
vim-latexsuite 1%3A1.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 5,424 kB
  • sloc: xml: 5,159; python: 906; makefile: 92; perl: 59; sh: 14
file content (27 lines) | stat: -rw-r--r-- 654 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def GetTextFromElementNode(element, childNamePattern):
    children = element.getElementsByTagName(childNamePattern)
    texts = []
    for child in children:
        texts.append(GetText(child.childNodes))

    return texts


def GetText(nodelist):
    rc = ""
    for node in nodelist:
        if node.nodeType == node.TEXT_NODE:
            rc = rc + node.data
    return rc


def GetTextFromElement(element):
    text = ""
    child = element.firstChild
    while not child.nextSibling is None:
        child = child.nextSibling
        print(child)
        if child.nodeType == child.TEXT_NODE:
            text = text + child.data

    return text