1

i'm ussing xpath to parse html with no problems until I found the code below.

I usually use the "textContent" property one I got this td with ax xpath query, BUT I need to get only the text BEFORE the <img tag.

   <td class="rowdispari">
                                ZONA NON SERVITA QUOTIDIANAMENTE-PROSSIMA CONSEGNA

                                                &nbsp;
                        <img onmouseover="caricaTool()" src="template/img/infoTip.png" width="17">
                            <div class="bottom" id='tooool'>
                                <div class="contenuto">
                                    <div class="top">
                                        <font class="testobold"><font class='testoblubold'>ZONA NON SERVITA QUOTIDIANAMENTE - PROSSIMA CONSEGNA </font><br>La località di destinazione non è tra quelle servite quotidianamente da SDA. La consegna avverrà al più presto possibile, compatibilmente con le operazioni logistiche.</font>
                                        <p>&nbsp;<br><a href="javascript:chiudiTool()"><u>Chiudi</u></a>
                                    </div>
                                </div>
                            </div>

                            </td>

2 Answers 2

1

You can probably use:

//td[@class="rowdispari"][img[@src="template/img/infoTip.png"]]/text()[1]

or:

//td[@class="rowdispari"]/text()[following-sibling::img[@src="template/img/infoTip.png"]][1]
Sign up to request clarification or add additional context in comments.

Comments

0

Assuming that you already have XPath to get the outer <td> element, you can simply append the XPath with /text()[1] to get the first text node that is direct child of current <td> element :

path_to_td_here/text()[1]

more concrete example :

//td[@class='rowdispari']/text()[1]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.