Reputation: 147
i'm trying to XML Reading by using DataProvider. i'm using VS 2015.
code is here in 'MainWindow.xaml'
<Window.Resources>
<XmlDataProvider x:Key="XmlData" Source="/config.xml" XPath="Settings" />
</Window.Resources>
but, my program couldn't read xml file. i put that 'config.xml' file in '/bin/debug' and '/bin' both are not working. but absolute path, 'c:\config.xml' is working!
where i can put xml file?? or can i use getting application path method in xml source file??
Upvotes: 0
Views: 61
Reputation: 760
For relative path use Pack URI
<Window.Resources>
<XmlDataProvider x:Key="XmlData" Source="pack://application:,,,/config.xml" XPath="Settings" />
</Window.Resources>
Upvotes: 1