Reputation: 8474
I have a html table from which I want to remove rows with a certain class.
However: When I try sed 's/<tr class="expandable">.*<\/tr>//g
it just does nothing (say: does not remove the tag)
An example input could be:
<tr><td>Some col</td></tr>
<tr class="expandable">
<td colspan="6">
<div class="expandable-content">
<p>Holds ACCA Practising Certificate: This indicates a member holding a practising certificate issued by ACCA. This means that the member is authorised to provide a range of general accountancy services to individuals and businesses, including business and tax advice and planning, preparation of personal and business tax returns, set up of book-keeping and business systems, providing book-keeping services, payroll work, assistance with management accounting help with raising finance, budgeting and cash-flow advice, business start-up advice and expert witness.</p>
</div>
</td>
</tr>
I am not a sed
pro and appreciate any help you can give me!
Upvotes: 0
Views: 34
Reputation: 246764
Assuming your html is valid XML, you can use a tool like xmlstarlet:
xmlstarlet ed -d '//tr[@class="expandable"]' <<ENDHTML
<html><body><table>
<tr><td>Some col</td></tr>
<tr class="expandable">
<td colspan="6">
<div class="expandable-content">
<p>Holds ACCA Practising Certificate: This indicates a member holding a practising certificate issued by ACCA. This means that the member is authorised to provide a range of general accountancy services to individuals and businesses, including business and tax advice and planning, preparation of personal and business tax returns, set up of book-keeping and business systems, providing book-keeping services, payroll work, assistance with management accounting help with raising finance, budgeting and cash-flow advice, business start-up advice and expert witness.</p>
</div>
</td>
</tr>
</table></body></html>
ENDHTML
<?xml version="1.0"?>
<html>
<body>
<table>
<tr>
<td>Some col</td>
</tr>
</table>
</body>
</html>
Upvotes: 2