i want to replace the last occurence of <li>
to add class inside it, it should look like below. <li class="last">
<li><span>Vislink Acquires Gigawave for US$6 Million </span></li>
<li><span>Newegg Offers $25 7-inch DTV</span></li>
<li><span>The Hope of Broadcasters </span></li>
<li><span>ICANN Approves Custom Domain Extensions </span></li>
<li><span>Sciences Ending U.S. Sales </span></li>
<li><span>LightSquared Proposes Plan to </span></li>
<li><span>Wimbledon Gets 3D upgrade </span></li>
<li><span>The Hope of Broadcasters </span></li>
<li><span>LightSquared Proposes Plan to </span></li>
<li class="last"><span> Newegg Offers $25 7-inch DTV </span></li>
i have stored the above html in a string variable. what could i do to achieve this.
If you are doing this in code behind, which is what I perceive to be the case, try someting like:
var last = htmlString.LastIndexOf("<li>");
htmlString = htmlString.Remove(last, 4).Insert(last, "<li class=\"last\"");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With