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.
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.
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.