Retrieve data from XmlDataProvider with XPath

image_pdfimage_print


   
    

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="XML Data Binding">
  <Window.Resources>
    <XmlDataProvider x:Key="dataProvider" XPath="Employees">
      <x:XData>
        <Employees xmlns="">
          <Employee Type="Beginner">
            <YearOfWorking>1</YearOfWorking>
          </Employee>
          <Employee Type="Intermediate">
            <YearOfWorking>2</YearOfWorking>
          </Employee>
          <Employee Type="Advanced">
            <YearOfWorking>3</YearOfWorking>
          </Employee>
        </Employees>
      </x:XData>
    </XmlDataProvider>
  </Window.Resources>
  <Grid>
    <ListBox ItemsSource="{Binding Source={StaticResource dataProvider},XPath=Employee/YearOfWorking}" />
  </Grid>
</Window>