I need to create an HtmlHelper in my MVC application that displays some nested and rather complex UL / LI (tree) structures. The HtmlTextWriter and XmlTestWriter provide tools for creating proper HTML, but they are advanced, which makes my work quite difficult, because after you provide the tag, you don’t have a link to the “parent” tag.
XDocument and XElement were the next candidates that I looked at, but they were created for XML, not HTML, which could lead to invalid HTML (self-closing tags, etc.).
How can i do this?
This alleged duplicate is not really a duplicate and does not answer my question at all. It's about creating an HTML-Helper rendering of one Html tag. This is not what I want. I would like to know how to build a whole DOM in C # code.
Mats source share