tags:

views:

700

answers:

2

Hi, 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? Thanks

+6  A: 

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);
Stevo3000
+1  A: 

It also works with XDocument.Parse

Thanks

pistacchio
I've changed my answer to use Parse as that is the method that shows up in the MSDN help.
Stevo3000