Reputation: 11
I have parts of html for parsing:
<a href="/res/" class="postbtn-reply-href" name="112309691"></a>
<blockquote id="m112309691" class="post-message"> text </blockquote>
How can I do it with different attributes?
<a>
attribut is ["name"]<blockquote>
it is text()something like:
Elements elements = doc.select("a [class=postbtn-reply-href]["name"], blockquote[class=post-message] [text()]");
Upvotes: 1
Views: 298
Reputation: 43033
What about this CSS selector?
a.postbtn-reply-href[name], blockquote.post-message:contains(text)
DEMO: http://try.jsoup.org/~kPbUK0RX6brMZFZZH-U-u9yVukY
The initial CSS selector is understood like below by Jsoup:
a // Select node descendant of a anchor node (a),
[class=postbtn-reply-href] // having a class named postbtn-reply-href
["name"] // and an attribute called "name"
, // OR
blockquote[class=post-message] // Select a node descendant of any blockquote having a class named post-message
[text()] // and having an attribute called text()
References:
Upvotes: 1
Reputation: 51
try this (element.class-name)
doc.select("a.postbtn-reply-href[name=112309691]")+""+doc.select("blockquote.post-message").text();
Upvotes: 0