How to avoid System.Xml.Linq.XElement escaping HTML content?

前端 未结 4 1227
孤城傲影
孤城傲影 2020-12-18 03:36

I\'m using the XElement object to build some HTML in the code-behind on an ASP.NET page.

I may or may not add some XAttributes to this XElement as I go along, in the

4条回答
  •  悲&欢浪女
    2020-12-18 04:16

    I resolved this by using the HtmlAgilitypack to convert the string of HTML into a hierarchical object.

    I then looped through each HTML element in this object and created a nested XElement for each.

    There's a little bit of checking that needs done on every element, but it works perfectly and has fewer lines of code than I expected when I started building it.

提交回复
热议问题