简体   繁体   中英

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:info@aoec.com">info@aoec.com</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.

试试JSoup ,强烈推荐。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM