1

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?

2
  • Hi, what about a regex looking for class='myclassname' ? Commented Mar 10, 2011 at 9:31
  • Regex is my last resort ;) I was hoping for more elegant solution. Commented Mar 10, 2011 at 9:36

2 Answers 2

2
  1. Use HtmlAgilityPack
  2. Use XPath to select the node something like this

    HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[@class='myClassName']");

  3. Put the extracted node string in your page where you want.

Sign up to request clarification or add additional context in comments.

1 Comment

I extracted nodes using HtmlAgilityPack & put it on page on LiteralControl. It worked well. Thanks.
1

Try a HTML Parser for that. Such as HTML Agility Pack

Then you can query as you wish.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.