0

So far I used HtmlAgilityPack for building Html documents.

The problem is that it is not stable, I get Stackoverflow Exceptions and it doesn't support jQuery syntax.

What I am trying to use to build Html documents is CsQuery.

My question is: Is it designated for building Html documents?

I like the functions it offers, but I cannot render the modified html document.

For example:

  CQ fragment= CQ.CreateFragment("<p>some text</p>");
  CQ html = CQ.CreateFromFile(@"index.html");
  CQ modified_html= html.Select("#test").Append(fragment);

Which means, I want to append fragment variable to element with id "test".

the problem is that I expect modified_html.Render() to return the modified version (including < p> sometext < /p> added to #test element), but it actually doesn't!!!

is there anyway to achieve this?

Nizar Blond
  • 1,826
  • 5
  • 20
  • 42

1 Answers1

3

Actually it does. I also checked with your code, it do append <p>some text</p> to the modified_html. The only possible issue I can think: there is no element with id = "test" in index.html. You may also want to save modified html to file so it will be easier for you to examine the output :

modified_html.Save(@"index_modified.html");
har07
  • 88,338
  • 12
  • 84
  • 137