html = """
...
<tt class="descname">all</tt>
<big>(</big>
<em>iterable</em>
<big>)</big>
<a class="headerlink" href="#all" title="Permalink to this definition">¶</a>
...
"""
I want to get all text between starting tag big upto before the first occurrence of a tag. This means if I take this example, then i must get (iterable) as a string.
I would avoid nextSibling, as from your question, you want to include everything up until the next
<a>, regardless of whether that is in a sibling, parent or child element.Therefore I think the best approach is to find the node that is the next
<a>element and loop recursively until then, adding each string as encountered. You may need to tidy up the below if your HTML is vastly different from the sample, but something like this should work: