<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

XmlDocumentWrapper

using System.Runtime.CompilerServices; using System.Xml; namespace Newtonsoft.Json.Converters { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] internal class XmlDocumentWrapper : XmlNodeWrapper, IXmlDocument, IXmlNode { private readonly XmlDocument _document; [System.Runtime.CompilerServices.Nullable(2)] public IXmlElement DocumentElement { [System.Runtime.CompilerServices.NullableContext(2)] get { if (_document.DocumentElement == null) return null; return new XmlElementWrapper(_document.DocumentElement); } } public XmlDocumentWrapper(XmlDocument document) : base(document) { _document = document; } public IXmlNode CreateComment([System.Runtime.CompilerServices.Nullable(2)] string data) { return new XmlNodeWrapper(_document.CreateComment(data)); } public IXmlNode CreateTextNode([System.Runtime.CompilerServices.Nullable(2)] string text) { return new XmlNodeWrapper(_document.CreateTextNode(text)); } public IXmlNode CreateCDataSection([System.Runtime.CompilerServices.Nullable(2)] string data) { return new XmlNodeWrapper(_document.CreateCDataSection(data)); } public IXmlNode CreateWhitespace([System.Runtime.CompilerServices.Nullable(2)] string text) { return new XmlNodeWrapper(_document.CreateWhitespace(text)); } public IXmlNode CreateSignificantWhitespace([System.Runtime.CompilerServices.Nullable(2)] string text) { return new XmlNodeWrapper(_document.CreateSignificantWhitespace(text)); } public IXmlNode CreateXmlDeclaration(string version, [System.Runtime.CompilerServices.Nullable(2)] string encoding, [System.Runtime.CompilerServices.Nullable(2)] string standalone) { return new XmlDeclarationWrapper(_document.CreateXmlDeclaration(version, encoding, standalone)); } public IXmlNode CreateProcessingInstruction(string target, string data) { return new XmlNodeWrapper(_document.CreateProcessingInstruction(target, data)); } public IXmlElement CreateElement(string elementName) { return new XmlElementWrapper(_document.CreateElement(elementName)); } public IXmlElement CreateElement(string qualifiedName, string namespaceUri) { return new XmlElementWrapper(_document.CreateElement(qualifiedName, namespaceUri)); } public IXmlNode CreateAttribute(string name, [System.Runtime.CompilerServices.Nullable(2)] string value) { return new XmlNodeWrapper(_document.CreateAttribute(name)) { Value = value }; } public IXmlNode CreateAttribute(string qualifiedName, [System.Runtime.CompilerServices.Nullable(2)] string namespaceUri, [System.Runtime.CompilerServices.Nullable(2)] string value) { return new XmlNodeWrapper(_document.CreateAttribute(qualifiedName, namespaceUri)) { Value = value }; } } }