1
Dim task As XElement = <task>
                               <body>body</body>
                               <optional><%= myVar %></optional>

                           </task>

<optional>反正有什么时候删除myVar Is Nothing吗?

4

1 回答 1

1

您可以使用 IIf

    Dim task As XElement = <task>
                               <body>body</body>
                               <%= IIf(String.IsNullOrEmpty(myVar), "", <optional><%= myVar %></optional>) %>
                           </task>
于 2011-11-22T21:49:14.987 回答