Read XML File using LINQ with

Good Morning! All is well in Wisconsin as the Bears were destroyed by the Green Bay Packers yesterday AND the Minnesota Vikings lost as well. It just does not get better than that.

The topic today is reading an XML file using LINQ for a Silverlight application I am working on. Make it a great day!

Private Sub startXml()
    Dim client As New WebClient()
    AddHandler client.OpenReadCompleted, AddressOf finishXml
    client.OpenReadAsync(New Uri("Resources/wlsl-manifest.xml", UriKind.Relative))
End Sub
Private Sub finishXml(ByVal sender As Object, ByVal e As OpenReadCompletedEventArgs)
    ‘ Create a new StreamReader instance using the specified Stream object.
    Using streamreader As New StreamReader(e.Result)
        Dim manifest As XDocument = XDocument.Load(streamreader)
        Dim slides As IEnumerable(Of XElement) = manifest.Element("Slides").Elements("Slide")
        For Each slide As XElement In slides
            Dim assembly As String = slide.Element("Assembly").Value
    End Using
End Sub

Join me on Facebook


  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: