Friday, May 1, 2009

Tip to fetch XML using LINQ

Function FetchXML(ByVal url As Uri) As XElement

Dim x = WebRequest.Create(url)

Using r = x.GetResponse, rs As New StreamReader(r.GetResponseStream)

Return XElement.Parse(rs.ReadToEnd)

End Using

End Function

Call the function with the location of the xml file to get the corresponding XML element, that can be used for needed purpose.

No comments: