我正在尝试使用htmlagilitypack删除节点,但一直都没有成功。 这是html的样子: example1:
<tr><td class="RL">Begindate:</td><td class="RL" colspan="3">12/1/2014<br/></td></tr>
<tr><td class="QL">Company Name:</td><td class="QL" colspan="3">
Abd El & Jake Holdings, LLC<br/><span class="upd">in business since 12/1/2014</span><br/></td></tr>
<tr></tr><tr><td class="RL">Address:</td><td class="RL" colspan="3">
North 10th Street, 18049
<tr><td class="RL" colspan="3"><a onclick="showPopWin('showOnMap.html?
address=North 10th street;city=Emmaus;country=&
compname=Consistoire%2bde%2bla%2bSynagogue', 680, 360, null); return false;" href="showOnMap.html?address=North 10th street&
city=Emmaus&country=&
compname=Consistoire%2bde%2bla%2bSynagogue">
<img title="img" alt="img" src="/kbopub/images/pin12.gif" class="edit"/></a></td></tr>
<tr><td class="QL">Status:</td><td class="QL" colspan="3">InActive
<br/>
example2:
<tr><td class="RL">Begindate:</td><td class="RL" colspan="3">1/1/2004<br/></td></tr>
<tr><td class="QL">Company Name:</td><td class="QL" colspan="3">
ABC Company, LLC<br/><span class="upd">in business since 1/1/2002</span><br/></td></tr>
<tr></tr><tr><td class="RL">Address</td><td class="RL" colspan="3"> Central Parkway, 11902
<tr><td class="RL" colspan="3"><<a onclick="showPopWin('showOnMap.html?
address=Central%2bParkway%252C+11902&
city=FL+32224+Jacksonville%2bflorida&
country=America&
compname=Abd', 680, 360, null); return false;"
href="showOnMap.html? address=Central%2bParkway%252C+11902&city=FL+32224+Jacksonville%2bflorida&country=Am erica&compname=Abd">
<img title="img" alt="img" src="/kbopub/images/pin12.gif" class="edit"/></a></td></tr>
<tr><td class="QL">Status:</td><td class="QL" colspan="3">Active<br/>
我用过
var QRnode = hdoc.DocumentNode.SelectNodes("//td[@class='RL']");
但是这显示了整个节点。如何删除标记中的所有元素?
由于 Rashmi
答案 0 :(得分:1)
使用此功能,您可以单独删除每个tag
:
var documentNode = document.DocumentNode;
var RL = documentNode.SelectSingleNode("//td[@class='RL']");
RL.Remove();
要删除所有内容,您需要使用之前的代码迭代所有tags
。