Rashmi
Rashmi

Reputation: 121

HTMLAgilitypack remove <a> node

I am trying to remove a node using htmlagilitypack and have been unsuccessful. Here's how the html looks like: 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,&nbsp;18049
    <tr><td class="RL" colspan="3"><a onclick="showPopWin('showOnMap.html?
    address=North 10th street;city=Emmaus;country=&amp;
    compname=Consistoire%2bde%2bla%2bSynagogue', 680, 360, null); return false;" href="showOnMap.html?address=North 10th street&amp;
    city=Emmaus&amp;country=&amp;
    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,&nbsp;11902
   <tr><td class="RL" colspan="3"><<a onclick="showPopWin('showOnMap.html?
   address=Central%2bParkway%252C+11902&amp;
   city=FL+32224+Jacksonville%2bflorida&amp;
   country=America&amp;
   compname=Abd', 680, 360, null); return false;"
   href="showOnMap.html?    address=Central%2bParkway%252C+11902&amp;city=FL+32224+Jacksonville%2bflorida&amp;country=Am   erica&amp;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/>

I used

var QRnode = hdoc.DocumentNode.SelectNodes("//td[@class='RL']"); 

But this shows the whole node. How can I remove all the elements in tag?

Thanks Rashmi

Upvotes: 0

Views: 1838

Answers (1)

Victor Sigler
Victor Sigler

Reputation: 23451

With this you can remove each tag independently:

var documentNode = document.DocumentNode;
var RL = documentNode.SelectSingleNode("//td[@class='RL']");
RL.Remove();

For delete all you need to iterate over all the tags with you previous code.

Upvotes: 1

Related Questions