c# - How to delete an input based on id and value in Html agility pack -


given below html parsed agility pack

<table>     <tbody>         <tr>             <td colspan="1">                 <p>name*</p>                 <p>                     <input type="text" size="24" title="name" id="name" name="name" />                 </p>             </td>         </tr>         <tr>             <td colspan="1">                 <p>age*</p>                 <p>                     <input type="text" size="24" title="age" id="age" name="age" />                 </p>             </td>         </tr>         <tr>             <td colspan="1">                 <p>date*</p>                 <p>                     <input type="text" size="24" title="date" id="date" name="date" />                 </p>             </td>         </tr>         <tr>             <td colspan="1">&#160;</td>         </tr>         <tr>             <td>&#160;<span>&#160;<input type="text" id="txtcaptcha" readonly="readonly" />&#160;     <input type="button" onclick="rendercaptcha()" value="refresh" /><br />&#160;     <input type="text" style="width: 140px;" id="txtverification" /></span> &#160;             </td>         </tr>         <tr>             <td colspan="1">                 <p id="radetempnode">&#160;                     <input type="submit" class="brochur" value="submit" id="complaintformsubmit" /> &#160;                     <input type="button" class="brochur" value="reset" id="complaintformreset" /> &#160;                 </p>             </td>         </tr>     </tbody> </table> 

i want remove inputs id complaintformreset,complaintformsubmit,txtverification , 1 value refresh.

is there way this?

given below code have tried

       var document = new htmldocument();         document.loadhtml(html);         var nodes = new queue<htmlnode>(document.documentnode.descendants());          while (nodes.count > 0)         {              var node = nodes.dequeue();             //if (node.name != "strong" && node.name != "em" && node.name != "u" && node.name != "#text")             if(node.id!="")             {              var parentnode = node.parentnode;                  if (node.attributes["id"] != null && (string.compare(node.attributes["id"].value, "txtverification", stringcomparison.invariantculture) == 0 || string.compare(node.attributes["id"].value, "complaintformsubmit", stringcomparison.invariantculture) == 0 || string.compare(node.attributes["id"].value, "complaintformreset", stringcomparison.invariantculture) == 0))                 {                     if (null != node.parentnode)                     {                         parentnode.removechild(node, true);                         //nodes.enqueue(node);                     }                     //node.removeall();                 }             }         }          string dd =document.documentnode.innerhtml;// final htm still contains node had tried remove 

is there wrong me?


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -