I try to serialize a simpley array:
XML file looks like:
I'm getting an error when I'm trying to Deserialize:
An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll
Additional information: There is an error in XML document (0, 0).
What's the problem of my code?
Code:
Dim arr() As Integer = {1, 2, 3, 4}
Dim tmpStream As New IO.FileStream("C:\str.xml", IO.FileMode.Create)
tmpSerializer = New XmlSerializer(GetType(Integer()))
tmpSerializer.Serialize(tmpStream, arr)
arr = tmpSerializer.Deserialize(tmpStream)
XML file looks like:
Code:
<?xml version="1.0" ?>
- <ArrayOfInt xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance">[/URL]
<int>1</int>
<int>2</int>
<int>3</int>
<int>4</int>
</ArrayOfInt>
An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll
Additional information: There is an error in XML document (0, 0).
What's the problem of my code?