1
<div dir="ltr">
  <div>1 Tom</div>
  <div>2 Anna</div>
  <div>3 Alex</div>
  <div>4 Jax<br /></div>
</div>
<br />
<div class="gmail_quote">
  <div class="gmail_attr">
  .......Somethings  
</div>
</div>

How can I get all content inside tag <div dir="ltr"> like this :

1 Tom 2 Anna ...

3
  • 3
    Well, you can use some built-in objects, such as XDocument. Do some research and try to solve the task on your own. Come back with specific problem :) Commented Jan 15, 2020 at 8:06
  • you need javascript to take the value correctly, else u need to use the server control to get it Commented Jan 15, 2020 at 8:07
  • What is the context? What is generating the HTML? How are you loading it into your C# program? Commented Jan 15, 2020 at 8:16

1 Answer 1

2

There is NuGet called called https://html-agility-pack.net/ which is pretty convenient to use:

var doc = new HtmlDocument();
doc.Load(filePath);

var query = $"div[@dir='ltr']";
HtmlNode node = doc.DocumentNode.SelectSingleNode(query);
string content = node.InnerHtml;
Sign up to request clarification or add additional context in comments.

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.