Hardik Lotiya
Hardik Lotiya

Reputation: 370

jsoup : Extract Tags between two <img>

Here is my code.

<table width="100%" cellspacing="0" border="0" cellspadding="20">
    <tbody>
    <tr>
        <td valign="top" height="50px" align="center">
            <span class="footer">Contact Sue Simmons on: tel:
            <strong>+44 (0)1727 864806     
                <a href="mailto:[email protected]">[email protected]</a>
                <a href="http://www.aoec.com">www.aoec.com</a>
            </strong>
            </span>
            <br>
            <a href="https://twitter.com/theaoec/">
                <img class="style2" border="0" src="http://www.aoec.com/Images/Icons/twitter.png" alt="Twitter">
            </a>
            <a href="http://www.linkedin.com/groups/AoEC-2429085">
                <img class="style2" border="0" src="http://www.aoec.com/Images/Icons/linkedIn.png" alt="LinkedIn">
            </a>
        </td>
    </tr>
    </tbody>
</table>

I want to find out the tags between two image tags. I tried it using nextSiblingElement() but it didn't work because the <a> tag causes a problem.

in the above code i put a code as mentioned below

Document cc = Jsoup.parse(html);

Elements imageElements = cc.select("img");

now i get the first tag when extract it. so i want to check it with the next that this two image are separated by td, p, div.

Upvotes: 1

Views: 326

Answers (2)

Zarathustra
Zarathustra

Reputation: 2943

There is nothing between your image tags. they are inside an "a" Tag.

Please add to your question the text which you want to get.

Upvotes: 0

Pez Cuckow
Pez Cuckow

Reputation: 14412

Try JSoup, Highly recommended.

Upvotes: 1

Related Questions