Reputation: 3
I have an XDocument loaded with LoadOptions.SetLineInfo. I need to take a copy of this object, preserving the line info.
Unfortunately, the copy constructors seem to lose the line info - as does a ToString / Parse.
Any ideas? Thanks.
Upvotes: 0
Views: 241
Reputation: 2836
You can try creating new XDocument from the old one. Somthing like this.
XDocument original = ....
using(var reader = original.CreateReader())
{
var copy = XDocument.Load(reader, LoadOptions.SetLineInfo);
}
This should do the trick.
Upvotes: 1