How do you force explicit tag closing with Linq XML?

前端 未结 4 1123
轻奢々
轻奢々 2020-12-20 13:09

This is the same question as: Explicit Element Closing Tags with System.Xml.Linq Namespace

but I use Net 4.0 and the answers do not work anymore.

The problem i

4条回答
  •  囚心锁ツ
    2020-12-20 13:57

    set the value of the XElement to String.Empty

    OR

    setting the IsEmpty property to false for all elements not having any child nodes

        foreach (XElement childElement in
            from x in document.DescendantNodes().OfType()
            where x.IsEmpty
            select x)
        {
            childElement.IsEmpty = false;
        }
    

提交回复
热议问题