B
Boris
I'm writting a console application and i want to store my ArrayList of
objects into XML document. Is there any way i can do that ?
Greets.
objects into XML document. Is there any way i can do that ?
Greets.
Nicholas Paldino said:Boris,
Are you iterating through each element of the ArrayList and serializing
them? It appears that is what you are doing. You want to change this so
that you serialize only the ArrayList itself, not the elements in it.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Boris said:Thanks Nicholas,
but now i have another problem. When i serialize my ArrayList that is having
more than one object i am getting this error message in IE:
XML document must have a top level element. Error processing resource
'file:///D:/Documents and Settings/Administrator/My Documents/Visual Studio
Projects/ConsoleApplication38/bin/Debug/osoba.xml'.
After i had opened my xml file i saw that every object from ArrayList makes
one top level element and file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<NewDataSet xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<name>Mike</name>
<surname>Jones</surname>
</NewDataSet>
<?xml version="1.0" encoding="utf-8"?>
<NewDataSet xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<name>John</name>
<surname>Doe</surname>
</NewDataSet>
How can serialize ArrayList inside one <NewDataSet> ... </NewDataSet> ?
Greets.