Reputation: 4562
I'm working with XDocument
at the moment and trying to find a property for where the document was originally loaded from:
For example, this will load a file located at url:
XDocument doc = XDocument.Load(url);
To save, I would need to do:
XDocument.Save(url)
I may need to to pass doc
to another method in another class and have it save back to that location without passing the url along.
Is the 'url' value stored anywhere within the doc object?
Upvotes: 0
Views: 224
Reputation: 13022
Use the XObject.BaseUri
property.
But not to have it set to null
, you have to load your document with LoadOptions.SetBaseUri
set:
XDocument doc = XDocument.Load(url, LoadOptions.SetBaseUri );
Upvotes: 3