Adds support of XmlElement as one of the allowed objectType
This commit is contained in:
@@ -1431,9 +1431,9 @@ namespace Newtonsoft.Json.Converters
|
|||||||
#if !(DOTNET || PORTABLE)
|
#if !(DOTNET || PORTABLE)
|
||||||
if (typeof(XmlNode).IsAssignableFrom(objectType))
|
if (typeof(XmlNode).IsAssignableFrom(objectType))
|
||||||
{
|
{
|
||||||
if (objectType != typeof(XmlDocument))
|
if (objectType != typeof(XmlDocument) && objectType != typeof(XmlElement))
|
||||||
{
|
{
|
||||||
throw new JsonSerializationException("XmlNodeConverter only supports deserializing XmlDocuments");
|
throw new JsonSerializationException("XmlNodeConverter only supports deserializing XmlDocuments or XmlElement");
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlDocument d = new XmlDocument();
|
XmlDocument d = new XmlDocument();
|
||||||
@@ -1477,6 +1477,11 @@ namespace Newtonsoft.Json.Converters
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (objectType == typeof(XmlElement))
|
||||||
|
{
|
||||||
|
return document.DocumentElement.WrappedNode;
|
||||||
|
}
|
||||||
|
|
||||||
return document.WrappedNode;
|
return document.WrappedNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user