# .NET and More > Silverlight >  XmL file is not loading in Listbox

## dot_net_help

I have vb code along with xml.and  i need to populate simple xml file in list box in silverlight appliction ,but its not rendering any thing

```
<UserControl xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"  xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"  x:Class="SilverlightApplication1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">

    <Grid x:Name="LayoutRoot" Background="White">
        <ListBox x:Name="customersList" Width="400" Height="200" />
    </Grid>
</UserControl>
```



```
Private Sub PopulateCustomersList()
        Dim settings As New XmlReaderSettings()
        settings.XmlResolver = New XmlXapResolver()
        Dim reader As XmlReader = XmlReader.Create("Customers.xml")
        reader.MoveToContent()
        While reader.Read()
            If reader.NodeType = XmlNodeType.Element AndAlso reader.Name = "customer" Then
                customersList.Items.Add(New ListBoxItem())
            End If
            If reader.NodeType = XmlNodeType.EndElement AndAlso reader.Name = "customers" Then
                Exit While
            End If
        End While
        reader.Close()
    End Sub
```



```
 Private Sub Btn_hello_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)

        MessageBox.Show("Hello World")

        PopulateCustomersList()
           End Sub
```

----------


## dot_net_help

here is the .xml file 

```
<?xml version="1.0"?>
<customers>
  <customer id="10001" first="John" last="Smith" company="Donuts plc">jsmith@mymail.com</customer>
  <customer id="10002" first="Rete" last="Bandy" company="This Is Bloggers Co.">rete@superbloggers.com</customer>
  <customer id="10003" first="James" last="Bird" company="Timestone">james.bird@timestone.co.uk</customer>
  <customer id="10004" first="Sarah" last="McCauly" company="Automated Snowmen Ltd">smccauly@automatedsnowmen.com</customer>
  <customer id="10005" first="Pete" last="Rowan" company="Cooltec Consultants">pete.rowan@cooltec.com</customer>
</customers>
```

----------


## techgnome

What's a ListBoxItem? Doesn't surprise me nothing is rendering... I don't see where you extract any data from the XML and add it to the ListBox.

-tg

----------


## dot_net_help

took reference from here
http://www.vectorlight.net/tutorials...lverlight.aspx

and out put is showing over there

----------


## techgnome

of course THAT example works... the data was extracted from the XML:


```
 customersList.Items.Add(new ListBoxItem() { Content = reader.GetAttribute("last") +                        ", " + reader.GetAttribute("first") + " (" + reader.ReadInnerXml() + ")" });
```

When you copied it over and converted it to VB, you didn't inlcude the reader.GetAttribute parts...

-tg

----------


## dot_net_help

hmm, fair enough can u please correct the missing statment in this  i.e 

```
 While reader.Read()
            If reader.NodeType = XmlNodeType.Element AndAlso reader.Name = "customer" Then
                customersList.Items.Add(New ListBoxItem() Content = reader.GetAttribute("last") & ", " & reader.GetAttribute("first") & " (" & reader.ReadInnerXml() & ")" & )
            End If
            If reader.NodeType = XmlNodeType.EndElement AndAlso reader.Name = "customers" Then
                Exit While
            End If
        End While
```

----------

