Lets assume that I have retrieved page html using HttpWebRequest & StreamReader. Now I would like to cut one div from the loaded html and put it in literal on my asp.net page. I know that that div has css class content. How can I do it?
-
Hi, what about a regex looking for class='myclassname' ?Davide Piras– Davide Piras2011-03-10 09:31:51 +00:00Commented Mar 10, 2011 at 9:31
-
Regex is my last resort ;) I was hoping for more elegant solution.Robert.K– Robert.K2011-03-10 09:36:16 +00:00Commented Mar 10, 2011 at 9:36
Add a comment
|
2 Answers
- Use HtmlAgilityPack
Use XPath to select the node something like this
HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[@class='myClassName']");
Put the extracted node string in your page where you want.
1 Comment
Robert.K
I extracted nodes using HtmlAgilityPack & put it on page on LiteralControl. It worked well. Thanks.