0

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.

1 Answers1

1

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.

vasil oreshenski
  • 2,788
  • 1
  • 14
  • 21