嗨,我试图在vb.net中错误处理空白xml文件,原始xml看起来像这样。
<settings>
<connection = "aaaa" user = "bbbb" perm = "bgshs"
</settings>
问题是,我试图检查xml是否有根只有空白,然后把它发送到其他地方。如
<settings>
</settings>
试试这个
Imports System.Xml
Imports System.Xml.Linq
Module Module1
Sub Main()
Dim input As String = "<settings></settings>"
Dim element As XElement = XElement.Parse(Input)
If Not element.HasElements Then
Console.WriteLine("Has no elements")
Console.ReadLine()
End If
End Sub
End Module