csquery

CsQuery to parse a collection of li items

梦想与她 提交于 2020-01-12 08:25:33
问题 Here's my code: CQ dom = CQ.Create(htmlString); var items = dom[".blog-accordion li"]; foreach (var li in items) { var newTournament = false; var test = li["header h2"]; } Inside the foreach loop li turns into a IDomObject variable and I can no longer drill down further into it. Any suggestions? Here is the example HTML I'm trying to parse: <ul> <li> <header> <h2>Test</h2> </header> </li> <li> <header> <h2>Test 2</h2> </header> </li> <li> <header> <h2>Test 3</h2> </header> </li> </ul> I need

Parsing HTML with CSQuery

谁都会走 提交于 2020-01-09 10:48:13
问题 How can I retrieve the value from a div tag via the ID using CSQuery? For example, <h3> <div id='type'> Room 1 </div> <div id='price'> 145 </div> </h3> In this case I'd like to get the content inside type and price . 回答1: Ok, here is how you do this with a full working example. Html This includes your invalid/duplicate id html which you have no control over var html = @"<h3> <div id='lib_presta'> Chambre standard 1 pers du <span class=''>03/03/2014</span> au <span class=''>05/03/2014 </span>

ASP.NET - Parse / Query HTML Before Transmission and Insert CSS Class References

走远了吗. 提交于 2019-12-12 04:11:09
问题 As a web developer I feel too much of my time is spent on CSS. I am trying to come up with a solution where I can write re-usable CSS i.e. classes and reference these classes in the HTML without additional code in ASPX or ASCX files etc. or code-behind files. I want an intermediary which links up HTML elements with CSS classes. What I want to achieve: Modify HTML immediately before transmission Select elements in the HTML Based on rules defined elsewhere (e.g. in a text file relating to the

Traverse the dom with CsQuery

无人久伴 提交于 2019-12-06 14:15:16
I'm trying to learn how to use CsQuery to traverse a dom to get specific text. The html looks like this: <div class="featured-rows"> <div class="row"> <div class="featured odd" data-genres-filter="MA0000002613"> <div class="album-cover"> <div class="artist"> <a href="http://www.allmusic.com/artist/half-japanese-0000555654">Half apanese</a> </div> <div class="title"> <div class="label"> Joyful Noise </div> <div class="styles"> <div class="rating allmusic"> <div class="rating average"> <div class="headline-review"> </div> <div class="featured even" data-genres-filter="MA0000002572, MA0000002613"

CsQuery to parse a collection of li items

我怕爱的太早我们不能终老 提交于 2019-12-03 16:05:07
Here's my code: CQ dom = CQ.Create(htmlString); var items = dom[".blog-accordion li"]; foreach (var li in items) { var newTournament = false; var test = li["header h2"]; } Inside the foreach loop li turns into a IDomObject variable and I can no longer drill down further into it. Any suggestions? Here is the example HTML I'm trying to parse: <ul> <li> <header> <h2>Test</h2> </header> </li> <li> <header> <h2>Test 2</h2> </header> </li> <li> <header> <h2>Test 3</h2> </header> </li> </ul> I need to grab the text of each h2 element. This is done in order to keep CsQuery consistent with jQuery which