简体   繁体   中英

Load external XML file in a XmlDataProvider

I will load a Xml file into my project without including it to my Solution. Normally to load it is:

<XmlDataProvider x:Key="MyList" Source="Packages.xml" XPath="Packages"/>

Where in the source "Packages.xml" must be a XML that is included in my project. But how can I read a Xml that is not included in the proyect?

Thank you very much!

Greetings!

You can set the Source property to an Uri that contains the path name of the XML file:

string xmlFilePath = ...
var xmlDataProvider = (XmlDataProvider)Resources["MyList"];

xmlDataProvider.Source = new Uri(xmlFilePath);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM