Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load an XML from Resources

Tags:

c#

xml

resources

I have an embedded XML as Resource. When trying to load it like:

XDocument quoteDocument = XDocument.Load(Properties.Resources.Quotes);

I get an error:

UriFormatException

How to properly load an XML from resources?

like image 852
pistacchio Avatar asked May 12 '09 08:05

pistacchio


1 Answers

Use the following for XDocument

XDocument quoteDocument = XDocument.Parse(Properties.Resources.Quotes);

While this code works for XmlDocument

XmlDocument quoteDocument = new XmlDocument();
quoteDocument.LoadXml(Properties.Resources.Quotes);
like image 176
stevehipwell Avatar answered Oct 20 '22 00:10

stevehipwell