使用sed从html输入中删除标记

使用sed从html输入中删除标记,sed,xmlstarlet,Sed,Xmlstarlet,我有一个html表,我想从中删除具有特定类的行。 但是:当我尝试sed的/*//g时,它什么也不做(比如:不删除标记) 例如,输入可以是: <tr><td>Some col</td></tr> <tr class="expandable"> <td colspan="6"> <div class="expandable-content"> <p>Holds ACCA Pract

我有一个html表,我想从中删除具有特定类的行。 但是:当我尝试sed的/*//g时,它什么也不做(比如:不删除标记)

例如,输入可以是:

<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>

持有ACCA执业证书:指持有ACCA颁发的执业证书的会员。这意味着会员机构有权向个人和企业提供一系列一般会计服务,包括业务和税务咨询和规划、个人和企业纳税申报表的编制、簿记和业务系统的建立、簿记服务、工资工作、,协助管理会计,提供融资、预算和现金流建议、创业建议和专家见证


我不是
sed
pro,非常感谢您能给我的任何帮助

假设您的html是有效的XML,您可以使用以下工具:


xmlstarlet ed-d'//tr[@class=“expandable”]假设您的html是有效的XML,您可以使用以下工具:


xmlstarlet ed-d'//tr[@class=“expandable”]”强制链接。“您尝试过使用XML解析器吗?”->xmllint和xidel都不能删除特定的行“类型”-至少我不知道有什么方法我认为显示的示例输入中有输入错误,最后一行可能是
。。。这可能有效
perl-0777-pe的|.*| | | gs'文件
,但并不像强制性链接指出的那样健壮。“您尝试过使用XML解析器吗?”->xmllint和xidel都不能删除特定的行“类型”-至少我不知道有什么方法我认为显示的示例输入中存在键入错误,最后一行可能是
。。。这可能可以工作于perl-0777-pe的|.| | | | gs文件
,但不像前面指出的那样健壮
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>