문제

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?

도움이 되었습니까?

해결책

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");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top