My DOM:
<div class="testClass">
<a><span>some text</span> but this is the only text i want to select</a> </div>
I want to get the "but this is the only text i want to select" without also selecting "some text". After looking through other stackoverflow posts, and reading docs, I still cannot find a way to accomplish this.
The following code prints both of the above strings, I:E "some text but this is the only text i want to select".
Elements results = doc.getElementsByClass("testClass").select("a:not(a>span)");
for (Element element : results) { System.out.println(element.text()); }