So I have to parse HTML that is structured as such
<div>
Hello
<div name="DONOTWANT">
Text that I dont want and other junk
</div>
World
</div>
I require a solution that would retrieve the immediate text in a block of HTML. In this example, I would want "Hello World" while ignoring all other text. Are there any suggestions as to how I can do this with webdriver and selenium? I am programming in java but, if you have a solution in another language that can be translated over, I would take that as well.
Currently if I have something like
String foo = driver.findElement(By.xpath(".//div")).getText();
foo would contain "Hello Text that I dont want and other junk World" which is less than optimal.