Skip to content

Commit 7942a04

Browse files
committed
how to processs xsi:nil?
1 parent 398bb6e commit 7942a04

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Microsoft.VisualBasic.Core/src/Text/Xml/Linq/DeserializeHandler.vb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ Namespace Text.Xml.Linq
110110
Return xml.Replace($"xmlns=""{ReplaceXmlns}""", "")
111111
End Function
112112

113+
Const xsi As String = "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"""
114+
113115
''' <summary>
114116
''' This method have bugs when deal with the xml when it have
115117
''' multiple xml namespace value
@@ -118,9 +120,10 @@ Namespace Text.Xml.Linq
118120
''' <returns></returns>
119121
Public Function LoadXml(xml As String, Optional variants As Type() = Nothing) As T
120122
Call sb.Clear()
121-
Call sb.AppendLine("<?xml version=""1.0"" encoding=""utf-16"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""?>")
123+
Call sb.AppendLine("<?xml version=""1.0"" encoding=""utf-16""?>")
122124
Call sb.AppendLine(process(xml))
123125

126+
' removes of the default namespace definition, otherwise, the deserialization process will fail
124127
If Not ReplaceXmlns.StringEmpty Then
125128
Call sb.Replace($"xmlns=""{ReplaceXmlns}""", "")
126129
End If

0 commit comments

Comments
 (0)