Reputation: 11524
i am experimenting in extracting information from this file:
<tr id="ctl00_Body_mc_cErgebnisListe1_ctl02_InseratInfoTR" class="topangebot">
<td class="BildTD" rowspan="2"> <a href="/anzeiger/immoweb/Detail.aspx?InseratID=6629161&FromTopAngebot=true"><img border="0" src="http://images.derstandard.at/t/22/upload/imagesanzeiger/immoupload/2012/05/73/733de246-b4eb-425a-8705-2e8b50baff12.jpg" alt="" /></a> </td>
<td class="TitleTD" rowspan="2"> <span class="neu">TOP!</span> <strong><a href="/anzeiger/immoweb/Detail.aspx?InseratID=6629161&FromTopAngebot=true">Ihr Geld als sichere Anlage - Eigentum vom Feinsten - Jacquingasse 29</a></strong><br /><a href="/anzeiger/immoweb/Detail.aspx?InseratID=6629161&FromTopAngebot=true">Wien 3.,Landstraße, Wohnung</a><br /><span style="color: gray">Erstbezug, Parkettboden, Lift, Provisionsfrei, Kabel/Sat-TV</span> </td>
<td class="GroessenTD" rowspan="2"> </td>
<td class="PreisTD" style="border:none;"> </td>
</tr>
<tr id="ctl00_Body_mc_cErgebnisListe1_ctl02_InseratInfoTR" class="topangebot">
<td class="BildTD" rowspan="2"> <a href="/anzeiger/immoweb/Detail.aspx?InseratID=6629161&FromTopAngebot=true"><img border="0" src="http://images.derstandard.at/t/22/upload/imagesanzeiger/immoupload/2012/05/73/733de246-b4eb-425a-8705-2e8b50baff12.jpg" alt="" /></a> </td>
<td class="TitleTD" rowspan="2"> <span class="neu">TOP!</span> <strong><a href="/anzeiger/immoweb/Detail.aspx?InseratID=6629161&FromTopAngebot=true">Ihr Geld als sichere Anlage - Eigentum vom Feinsten - Jacquingasse 29</a></strong><br /><a href="/anzeiger/immoweb/Detail.aspx?InseratID=6629161&FromTopAngebot=true">Wien 3.,Landstraße, Wohnung</a><br /><span style="color: gray">Erstbezug, Parkettboden, Lift, Provisionsfrei, Kabel/Sat-TV</span> </td>
<td class="GroessenTD" rowspan="2">12312 </td>
<td class="PreisTD" style="border:none;">3123 </td>
</tr>
I want to select with my css query the title and the price from the same tr.topangebot at the same time. I tried this query:
Elements topangebotPars = doc.select("tr.topangebot > (td.TitleTD && td.GroesseTD)");
I got:
Could not parse query
How to select more than one element at the same time?
Upvotes: 0
Views: 414
Reputation: 1074268
Remember that the selectors used with select
are CSS selectors. So just like you'd write a comma-separated list of selectors in a CSS file, for instance:
tr.topangebot > td.TitleTD, tr.topangebot > td.GroesseTD {
color: blue:
}
...you do the same thing with select
:
Elements topangebotPars = doc.select("tr.topangebot > td.TitleTD, tr.topangebot > td.GroesseTD");
The JSoup documentation has a quick reference for selectors. They list this under "combinators" (although the CSS spec itself doesn't consider them "combinators," just a group).
Upvotes: 3