entity framework - How to extract outerhtml of div tag having class named story-body__inner using HTML Agility Pack and EF -
i extract whole outer html string using html agility pack. tried way unsuccessful.
part of htmldocument
<div class="story-body__inner" property="articlebody"> <figure class="media-landscape has-caption full-width lead"> <span class="image-and-copyright-container"> <img class="js-image-replace" alt="vice admiral joseph aucoin, u.s. 7th fleet commander, attends media briefing on status of u.s. navy destroyer uss fitzgerald, damaged colliding philippine-flagged merchant vessel, , 7 missing fitzgerald crew members, @ u.s. naval base in yokosuka, south of tokyo, japan 18 june 2017." src="https://ichef.bbci.co.uk/news/660/cpsprodpb/7af6/production/_97487413_308af0da-df48-40e4-80ca-3c4c35a8be7c.jpg" width="976" height="650" data-highest-encountered-width="660"> <span class="off-screen">image copyright</span> <span class="story-image-copyright">reuters</span> </span> <figcaption class="media-caption"> <span class="off-screen">image caption</span> <span class="media-caption__text"> vice adm joseph aucoin due retire position in coming weeks </span> </figcaption> </figure><p class="story-body__introduction">the navy has dismissed vice adm joseph aucoin commander of seventh fleet following string of collisions involving warships in asia. </p><p>ten sailors still missing after uss john s mccain collided oil tanker near singapore on monday.</p><p>navy officials human remains have since been found in sealed compartments on board ship, in port in singapore.</p><p>the crash fourth such incident in year.</p><p><a href="http://www.cpf.navy.mil/news.aspx/110335" class="story-body__link-external">in statement</a>, navy said had lost confidence in vice adm aucoin's ability command. </p><div id="bbccom_mpu_1_2_3" class="bbccom_slot mpu-ad" aria-hidden="true"> <div class="bbccom_advert"> <script type="text/javascript"> /**/ (function() { if (window.bbcdotcom && bbcdotcom.adverts && bbcdotcom.adverts.slotasync) { bbcdotcom.adverts.slotasync('mpu', [1,2,3]); } })(); /**/ </script> </div>
and code extract html as
ienumerable<htmlnode> mydivnodes = htmldocument.documentnode.descendants("div").where(x => x.name=="div" && x.attributes.contains("class")&& x.attributes["class"].value.split().contains("story-body__inner")); foreach (var node in mydiv) { result += node.outerhtml; } return result;
i got null in return.
any suggestion or sample code appreciated.
thank you.
wiki
Comments
Post a Comment