XPath filter on value

983 views Asked by At

I've got a ListBox with an XMLDataProvider that I want to filter on the specific value of a node.

I've tried the following but it returns the full <ITEMS> again.

<XmlDataProvider x:Key="ItemDataSource" XPath="./ITEMS[ITEM[./PROPERTY='value']]" Source="data.xml">
</XmlDataProvider>

This is the XML file:

<ITEMS>
  <ITEM>
    <PROPERTY>value</PROPERTY>
  </ITEM>
  <ITEM>
    <PROPERTY>other value</PROPERTY>
  </ITEM>
</ITEMS>

./ITEMS/ITEM[./PROPERTY/text()='value'] works but since it isn't wrapped by <ITEMS> it refuses to display the data.

1

There are 1 answers

0
Maartje Eyskens On

I've found the solution using ./ITEMS/ITEM[./PROPERTY/text()='value'] I needed to unset the XPath in ItemsSource.