There are several ways to validate XML...
Public Shared Function IsValidXml(xmlString As String) As Boolean
Dim tagsWithData As New Regex("<\w+>[^<]+</\w+>")
If String.IsNullOrEmpty(xmlString) OrElse tagsWithData.IsMatch(xmlString) = False Then
Return False
End If
Try
Dim xmlDocument As New XmlDocument()
xmlDocument.LoadXml(xmlString)
Return True
Catch xmlException As XmlException
Return False
End Try
End Function
N.B. Taken from here
Or you could simply handle the exception
Try
Dim document As XDocument = XDocument.Load("C:\Purchase Request Setup\Crystal reports\crptPurchaseRequest.xml")
Catch ex As XmlException 'Handle the exception
'Probably poorly formed XML...
End Try