Reputation: 976
I'm trying to open an HTML file, loop through the divs that match a certain criteria, and then loop through the p tags that match a certain criteria within those divs.
CQ dom = CQ.CreateFromFile("page.html");
CQ document_divs = dom["div"];
document_divs.Each((i,document_div) =>
{
string divid = document_div.Id;
if (divid.Contains("page"))
{
CQ page_ptags = document_div["p"];
page_ptags.Each((j, page_ptag) =>
{
lblOutput.Text = page_ptag.Id;
});
}
});
It is selecting the divs fine, but I'm not sure how to select the p tags within a div. I know there is something wrong with this line:
CQ page_ptags = document_div["p"];
But what should I change?
Upvotes: 1
Views: 917
Reputation: 503
When you are looking throw a CQ object, each elements will be type of IDom. That's why you need or wrap it in CQ object, or use native Dom functions to work with.
Upvotes: 0