Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is XDocument appropriate for generating HTML?

My goal is to use a WCF Service to accept some parameters, generate and then return a HTML string that a user can use to embed on certain webpages of their choice.

Is XDocument appropriate for generating a string of HTML?

I do not really need a full HTML document, just a simple snippet that has some image elements, a p-tag element, and a table element.

like image 762
Max Alexander Avatar asked Aug 18 '26 15:08

Max Alexander


1 Answers

It's suitable for generating XHTML, which is valid XML. It wouldn't be suitable for parsing HTML, which doesn't have to be a valid XML document.

There may be more HTML-specific APIs available, but for just a simple snippet of XHTML, using XDocument should be fine.

like image 106
Jon Skeet Avatar answered Aug 20 '26 09:08

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!