开发者

get elements from html parser

I'm using JSOUP, and trying to get the elements which start with a particular div tag id. For example:

<div id="test123">. 

I need to check if the elements starts with the string "test" and get all the elements.

I looked at http://jsoup.org/cookbook/extracting-data/selector-syntax and I tried a multiple variations using:

doc.select("div:matches(test(*))");

But it still didn't work. Any help wo开发者_开发技巧uld be much appreciated.


Use the attribute-starts-with selector [attr^=value].

Elements elements = doc.select("div[id^=test]");
// ...

This will return all <div> elements with an id attribute starting with test.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜