How can I use Linq to XML to extract content from webpage in C# or in Xamarin.Android -
i have attached image and content expanded <div> .... </div>
using linq xml in c#. tried way not sort out.
xdocument.parse(content); // linq xml xelement root = xelement.load(url); ienumerable<xelement> tests = el in root.elements("div") (string)el.element("confused") == "confused" select e foreach (xelement el in tests) console.writeline((string)el.attribute("confused"));
if there simple way extract content webpage having kind of structure using other techniques including xmldocument, xmlpullparser or linqtoxml, appreciate. thank you.
edited requested:
<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="us president donald trump arrives speak @ "make america great again" rally in phoenix, arizona, on august 22, 2017" src="https://ichef-1.bbci.co.uk/news/660/cpsprodpb/5256/production/_97487012_ad54fff5-3ff7-41ec-9e30-c239de238cc4.jpg" width="976" height="549" data-highest-encountered-width="660"> <span class="off-screen">image copyright</span> <span class="story-image-copyright">afp</span> </span> <figcaption class="media-caption"> <span class="off-screen">image caption</span> <span class="media-caption__text"> donald trump touched on immigration, healthcare , enemies during arizona rally </span> </figcaption> </figure><p class="story-body__introduction">donald trump has vowed close down government if necessary build wall along mexico border.</p><p>the president told supporters @ "make america great again" rally in phoenix, arizona, opposition democrats being "obstructionist".</p><p>during 80-minute speech, took aim @ media, blaming them giving far right groups "a platform".</p><p>but selectively quoted initial response violence @ far-right rally left 1 woman dead.</p><p>he omitted controversial claim <a href="http://www.bbc.co.uk/news/world-us-canada-40943425" class="story-body__link">"many sides" had shoulder blame</a> violence in charlottesville, virginia.</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> </div><p>in wide-ranging speech, mr trump said thought "probably end terminating nafta", trade deal mexico , canada.</p><p>on north korea, president sounded hopeful note possibility of reduction in tensions on pyongyang's missile tests , nuclear programme.</p><p>referring north korean leader kim jong-un, mr trump said: "i respect fact starting respect us".</p><p>"and maybe - not, maybe - positive can come about," added.</p><ul class="story-body__unordered-list"> <li class="story-body__list-item"><a href="http://www.bbc.co.uk/news/world-us-canada-40948812" class="story-body__link">charlottesville: made trump remarks offensive?</a></li> <li class="story-body__list-item"><a href="http://www.bbc.co.uk/news/world-us-canada-40946386" class="story-body__link">bush presidents wade trump furore </a></li> <li class="story-body__list-item"><a href="http://www.bbc.co.uk/news/business-40943041" class="story-body__link">nafta: @ stake?</a></li> </ul><p>but while comments met cheers inside conference centre, anti-trump protesters had gathered outside rally clashed police after rally had finished.</p><p>police deployed tear gas after protesters threw bottles , rocks, reuters news agency reported.</p><figure class="media-landscape has-caption full-width"> <span class="image-and-copyright-container"> <img src="https://ichef.bbci.co.uk/news/624/cpsprodpb/a076/production/_97487014_7815d739-c520-4475-a24d-8f5ccfcca705.jpg" datasrc="https://ichef.bbci.co.uk/news/320/cpsprodpb/a076/production/_97487014_7815d739-c520-4475-a24d-8f5ccfcca705.jpg" class="responsive-image__img js-image-replace" alt="large inflated figures of sheriff joe arpaio , president trump seen above ant-trump protesters outside phoenix convention center" width="976" height="549" data-highest-encountered-width="624"> <span class="off-screen">image copyright</span> <span class="story-image-copyright">getty images</span> </span> <figcaption class="media-caption"> <span class="off-screen">image caption</span> <span class="media-caption__text"> protesters hold inflatable joe arpaio, whom mr trump hinted pardon </span> </figcaption> </figure><p>president trump began , finished speech urging american people come together.</p><p>but turned on familiar foes, beginning media, said had misrepresented "perfect" words in wake of violence in charlottesville, heather heyer killed after car ploughed crowd of people protesting against far-right demonstrators including neo-nazis.</p><p>he accused "truly dishonest people in media , fake media" of "trying take away our history , heritage" because, said, "don't our country".</p><p>he quoted own initial public response happened in charlottesville.</p><p>"this said on saturday: 'we're closely following terrible events unfolding in charlottesville, virginia,' - me speaking. 'we condemn in strongest possible terms egregious display of hatred, bigotry , violence.' that's me speaking on saturday, right after event," said.</p><p>but said on 12 august was: "we condemn in strongest possible terms egregious display of hatred, bigotry , violence on many sides, on many sides."</p><p>mr trump's attention turned immigration, , democrats said "putting of america's safety @ risk" opposing wall wants build along us's southern border mexico.</p><ul class="story-body__unordered-list"><li class="story-body__list-item"><a href="http://www.bbc.co.uk/news/resources/idt-d60acebe-2076-4bab-90b4-0e9a5f62ab12" class="story-body__link">six things topple trump's wall</a></li></ul><p>he said immigration officers worked in area said "vital" stem flow of illegal immigrants.</p><p>mr trump concluded: "if have close down government, building wall."</p><p>mr trump used rally hint pardon controversial former arizona sheriff joe arpaio, man rose national prominence because of tough stance against illegal immigration.</p><figure class="media-landscape has-caption full-width"> <span class="image-and-copyright-container"> <img src="data:image/gif;base64,r0lgodlheaajaiaaap///waaach5baeaaaaalaaaaaaqaakaaaikhi+py+0po5yufqa7" datasrc="https://ichef-1.bbci.co.uk/news/320/cpsprodpb/ee96/production/_97487016_3eff3038-16fe-4f5a-963a-b36339e3320e.jpg" class="responsive-image__img responsive-image__img--loading js-image-replace" alt="supporters of u.s. president donald trump cheer him @ campaign rally in phoenix, arizona, u.s., august 22, 2017." width="976" height="549"> <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"> supporters heard chant "cnn sucks" during rally </span> </figcaption> </figure><p>he told crowd mr arpaio - <a href="http://www.bbc.co.uk/news/world-us-canada-40780659" class="story-body__link">found guilty of criminal contempt</a> in july - "is going fine", not formally pardon him @ moment because "i don't want cause controversy".</p><p>his comments directly contradicted of white house spokeswoman sarah sanders, said on tuesday "there no discussion of today".</p><p>mr arpaio, 85, found have violated judge's 2001 order cease detaining migrants not suspected of having committed state crime.</p> </div>
wiki
Comments
Post a Comment