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
.
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
C# Code
This loads the dom elements by their id's into two lists of descriptions and prices. It then projects them into a list of
HotelAvailability
objects using the key values of both collections as theHotelName
andPrice
properties.Run the above in a console app to test it.