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.

4

1 回答 1

1

您可以尝试从旧的 XDocument 创建新的 XDocument。像这样的东西。

XDocument original = ....
using(var reader = original.CreateReader())
{
    var copy = XDocument.Load(reader, LoadOptions.SetLineInfo);
}

这应该可以解决问题。

于 2017-01-26T10:54:44.310 回答