0

I have a table where in one column, I have saved all the html of a page. I want to fetch a div( and its contents) from that div using htmlagility how can I do this. I don't want to load it from url or do screen scraping.

2 Answers 2

1
// Load your html

HtmlDocument htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(html);
// Find div with an id or you could use a class if you want
var nodes = htmlDocument.DocumentNode.SelectNodes("//div[@id='myDivId']");
Sign up to request clarification or add additional context in comments.

Comments

0

I found this solution.

 HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(@html);

            HtmlNodeCollection tableRows = doc.DocumentNode.SelectNodes("//tr");

            string content = "";
            if (tableRows.Count > 1)
            {
                HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[@class='account-detail']");
               content = node.InnerHtml;
            }

thank you all for your time.

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.