I have an HTML snippet that I need to change around in Java, I have been using JSOUP to parse through, but I feel like it may not be as efficient. I uploaded pictures of what I am looking for here. Sorting from date of the TD news to oldest & if there is duplicat A hrefs delete the node as a whole. I have an arraylist of the given divs that will be included as well
ObservableList<String> names;
Im thinking the a way could be to foreach through the list and grab from that name all the way down until a div is hit? I feel like this is a simple problem and im over thinking it, thank you for the help!
foreach(String name: names)
{}
Sorted without duplicates example
HTML(no sort with duplicates):
<div>CHTR</div>
<td width="130" align="right" style="white-space:nowrap">Mar-04-20 08:54AM </td>
</br>
<a sname='CHTR' href="https://test.com/news/why-charter-chtr-stock-might-135401270.html" target="_blank" class="tab-link-news">Why Charter (CHTR) Stock Might be a Great Pick</a></br>
<td width="130" align="right">Mar-04-20 08:53AM </td>
</br>
<a sname='CHTR' href="https://test.com/news/charter-offers-senior-unsecured-notes-135400843.html" target="_blank" class="tab-link-news">Charter Offers Senior Unsecured Notes</a>.
</br>
<div>PEGI</div>
<td width="130" align="right" style="white-space:nowrap">Mar-04-20 12:49 PM </td>
</br>
<a sname='PEGI' href="www.test.com/news/3548648-pattern-energy-low-odds-of-competing-bid-raymond-james-says">Pattern Energy has low odds of competing bid, Raymond James says</a></br>
<div>CHTR</div>
<td width="130" align="right" style="white-space:nowrap">Mar-04-20 12:39 PM </td>
</br>
<a sname='CHTR' href="www.test.com/news/3548649-charter-offering-senior-notes">Charter offering more senior notes</a></br>
<div>PEGI</div>
<td width="130" align="right" style="white-space:nowrap">Mar-04-20 12:49 PM </td>
</br>
<a sname='PEGI' href="www.test.com/news/3548648-pattern-energy-low-odds-of-competing-bid-raymond-james-says">Pattern Energy has low odds of competing bid, Raymond James says</a></br>
<td width="130" align="right" style="white-space:nowrap">Mar-04-20 08:40 AM </td>
</br>
<a sname='PEGI' href="www.test.com/news/greatbuy">Great buy with PEGI</a></br>
Parsed the HTML and added them to a list, then created a custom Object, then two comparators to double sort the list.
Comparator<MyObject> compareByName = Comparator
.comparing(Article::getName);
Comparator<MyObject> compareByName2 = Comparator
.comparing(MyObject::getDate).reversed();
myList.sort(compareByName.thenComparing(compareByName2));