XML Desialization of array list

Here's a simple example (VB.NET):

Option Strict

What would the code look like to deserialize this example?  

Imports System
Imports System.Collections
Imports System.IO
Imports System.Xml.Serialization

Public Class App1

 Shared Sub Main()
        Dim list As ArrayList = New ArrayList()
        Dim out As StreamWriter = New StreamWriter("array.xml")
        Dim ser As XmlSerializer = New XMLSerializer(list.GetType())

        list.Add("a")
        list.Add("2")
        list.Add("three")

        ser.Serialize(out, list)
 End Sub
End Class
0
peter1140 (1)
12/1/2004 2:52:10 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
933 Views

Similar Articles

[PageSpeed] 40

Peter,
It's funny.  As often as I work with this stuff, sometimes I still get a 
hook.  But, it was really quite simple.

        Dim serializer As New 
System.xml.Serialization.XmlSerializer(GetType(ArrayList))
        ' A FileStream is needed to read the XML document.
        Dim fs As New System.IO.FileStream("C:\array.xml", 
System.IO.FileMode.Open)
        Dim reader As New System.Xml.XmlTextReader(fs)
        Dim list As ArrayList = CType(serializer.Deserialize(reader), 
ArrayList)
        Dim counter As Integer = 0
        For counter = 0 To list.Count - 1
            MessageBox.Show(list(counter))
        Next

Please let me know if you need anything else.

"Peter" wrote:

> Here's a simple example (VB.NET):
> 
> Option Strict
> 
> What would the code look like to deserialize this example?  
> 
> Imports System
> Imports System.Collections
> Imports System.IO
> Imports System.Xml.Serialization
> 
> Public Class App1
> 
>  Shared Sub Main()
>         Dim list As ArrayList = New ArrayList()
>         Dim out As StreamWriter = New StreamWriter("array.xml")
>         Dim ser As XmlSerializer = New XMLSerializer(list.GetType())
> 
>         list.Add("a")
>         list.Add("2")
>         list.Add("three")
> 
>         ser.Serialize(out, list)
>  End Sub
> End Class
> 
0
3/11/2005 11:31:03 PM
Also, I wanted to mention to you.  At the end of your serialize method, 
please make sure you close your file stream.

i.e. 
out.Close() in your case.

Also, do the same at the end of the deserialization.

fs.Close()

"Peter" wrote:

> Here's a simple example (VB.NET):
> 
> Option Strict
> 
> What would the code look like to deserialize this example?  
> 
> Imports System
> Imports System.Collections
> Imports System.IO
> Imports System.Xml.Serialization
> 
> Public Class App1
> 
>  Shared Sub Main()
>         Dim list As ArrayList = New ArrayList()
>         Dim out As StreamWriter = New StreamWriter("array.xml")
>         Dim ser As XmlSerializer = New XMLSerializer(list.GetType())
> 
>         list.Add("a")
>         list.Add("2")
>         list.Add("three")
> 
>         ser.Serialize(out, list)
>  End Sub
> End Class
> 
0
3/11/2005 11:35:01 PM
Reply:

Similar Artilces:

Outlook 2003 Global Address List
Hi, I have a couple of issues with the Outlook 2003 Global Address List: Firstly, the list appears not to be 'Global' as it appears to be different on some PCs to that listed in Exchange 2003 on the server. It may or may not be part of the same problem, but there doesn't seem to be any roll-out of changes either. Secondly, I've managed to add one new user to an 'all users' mailgroup, but unlike previous occasions, I haven't been able to add this user to the Exchange 2003 Address List. Please help! Thankyou very much. Keith Is Outlook 2003 configured for ...

How can I delete a list from a column?
Hello all -Excel 2003- I have a column L that call a list. When I want to insert a new column in M, this M columns takes also the list of L. I have now the same list in L and M. How can I delete the list from M? Thanks a lot. Select the column and Edit>Clear>Contents. Gord Dibben MS Excel MVP On Mon, 14 Aug 2006 11:20:51 +0200, "Casrlos A." <carlin334@msn.com> wrote: >Hello all -Excel 2003- > >I have a column L that call a list. When I want to insert a new column in >M, this M columns takes also the list of L. >I have now the same list in L a...

Investment account not in transaction list
I'm using Money 2001 and I've created a new investment account. Yet when I try to add a transaction to it, the drop-down list of investment accounts does not include the new one. Yet everywhere else in Money (account list, etc) the new account does appear. What gives? Any ideas? Thanks In microsoft.public.money, "AH UK user" <AH UK user@discussions.microsoft.com> wrote: >I'm using Money 2001 and I've created a new investment account. Yet when I >try to add a transaction to it, the drop-down list of investment accounts >does not include the new ...

Assembling Visual Studio generated listing files
I need to modify and assemble the assmelber listing files generated from the VS 2005 IDE. A test generated listing file did not assmeble 'as is'. Has any tried this? It seems to me the listing file should assemble. I hope there is some sane reason that would explain the need to do this. Shades of running 'sed' scripts on the output of the PDP-11 C compiler to create the Unix kernel! Since you do not explain what is meant by "did not assemble" it is hard to guess where the problem is. joe On Mon, 3 Dec 2007 10:50:57 -0800 (PST), TahoeKid <rfdunn@hotmail.c...

Global Address List Missing (Sometimes)
Ok, I am going to try and be as detailed as possible, but this is my second day on the job here. Windows 2003 SP1 and Exchange 2003 SP2, both are updated. The server is on site with the DC. Primary is a Win2k server and the backup is a Win2k3 server. The problem is that when clients are using Outlook 2003 or 2000, sometimes the GAL will not appear, resulting in them not being able to send internal corporate emails, unless of course they type out the full email address. But the problem seems to fluctuate, sometimes the GAL is listed and other times it is not, even within the same Outlo...

Dynamic "Numbered List"
How Can I update my numbered list (S.No) after Filtering the list? Like: 1. A 2. B 3. C 4. D After filter..... 1. A 2. B 3. D [C Filtered] Any Idea to get the result. Regards, Murtaza hi, Murtaza ! > ... update my numbered list (S.No) after Filtering the list? > Like: > 1. A > 2. B > 3. C > 4. D > After filter..... > 1. A > 2. B > 3. D [C Filtered] assuming [B2] as the first cell [in filtered-column]... try with subtotal-offset approach [by Laurent Longre] and copy-down... a) array-entered: {ctrl}+...

Fast way to re-assign large list of leads?
Hello; We have a list of leads from a marketing list (about 1,200) that got imported and assigned to the wrong user. Is there any fast way to assign all 1,200 of those leads to a different CRM user? I've been trying to go through 100 at a time, but it's taking forever :( Sincerely, Todd M. Taylor Only way is to write your own app using the SDK. I'd suggest keep doing 100 at time,...thats just 12 times! You'll spend far more time writing that app (unless you have significant experience with the CRM SDK) -Gary "Todd M. Taylor" <flygtiguy@NOSPAMhotmail.c...

Unable to Open URL which has long list of validationd or conditions
Hi This is prabhu here i have an issue with openeing an URL in Excel. tried is using Open workbook command (Works with small url) but not with long url if some one can help me with is, Would be great and super help to me in acheving my projects. looking for the help thanks Prabhu EggHeadCafe.com - .NET Developer Portal of Choice http://www.eggheadcafe.com ...

Global Address List Members in Excel Spreadsheet
Is there a way for me to transfer the members of a global address list to an Excel spreadsheet? Thanks! Indirectly check out http://www.slipstick.com/exs/portagal.htm for a method "Wendy" <anonymous@discussions.microsoft.com> wrote in message news:0c4201c3daa3$e8b36060$a301280a@phx.gbl... > Is there a way for me to transfer the members of a global > address list to an Excel spreadsheet? Thanks! ...

Multi Select List Not Working
The following code works perfectly for a multi select list. I've used it for several years on many applications. I'm encountering a strange error however on this code that takes criteria from three different lists and enters the data into a query. The first two list's criteria work fine but the third list has a strange quirk. Here's what it is doing. Let's say the third list has choices, 1,2,3,4,5,6. If I choose 3,4,5 in the list and run the code, it returns 1,4,5. If I choose 2,4,5,6 the code returns 1,4,5,6. It always returns the first value in my list wh...

Something wrong when xml control is not showing data
This is a multi-part message in MIME format. ------=_NextPart_000_0010_01C60F88.8BCE9BA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, I am using VB/ASP.net 2005. When I click submit it refreshes the page = without entering the data from all the text boxes and not entering in = the Game1.xml. here is the asp.vb code Imports System.Xml Partial Class _game1 Inherits Web.UI.Page ............... Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As = System.EventArgs) Handles btnSubmit.Click Dim xDoc As New XmlDocum...

alphabetize list
How do you sort/alphabetize a list in publisher 2002? Thanks Suzanne Hi sbrimley (sbrimley@discussions.microsoft.com), in the newsgroups you posted: || How do you sort/alphabetize a list in publisher 2002? || Thanks Suzanne You need to bring it in to Excel and sort, then put back in Publisher. -- Brian Kvalheim Microsoft Publisher MVP http://www.publishermvps.com ~pay it forward~ This posting is provided "AS IS" with no warranties, and confers no rights. How weird I would have thought that would have been a standard function. Thanks for you help, I will stopping searching f...

Distribution list #9
My company has a number of distribution groups. We are running Exchange 2003. I would like to only make the distribution group available from the inside. Is this possible? Thanks, Patrick yes...on the Exchange General tab of the group, select "from authenticated users only" in the "accept messages" section... "Patrick Adkinson" <padkinson@hotmail.com> wrote in message news:0b2c01c49cc7$2228f130$a501280a@phx.gbl... > My company has a number of distribution groups. We are > running Exchange 2003. I would like to only make the > distribution...

Distribution list no longer showing up
We recently migrated from Exchange 2k to Exchange 2003, everything seem to run pretty smoothly from the migration, but now the Distribution Lists from AD are not showing up in our Outlook2003 clients. All the users show up fine, just not the DLs created in the AD. The funny thing is that when sending an email, I'll type a particular DL, (companyX-clerks) in the TO field, and it will recognize it and complete it for me, then I'll hit send and it goes to all users in that group. But yet, the DLs is not showing up at all. Any ideas or help would be appreciated. Thanks. ...

Converting text and listnum fields to multi-level lists
I have many documents with numbered paragraphs. They use a mixture of text, listnum fields and multi-level lists to achieve the numbering. How can I convert them all to multi-level lists using VBA? ...

Excel Shopping List
Can any tell me where I can get a working copy of an Excel Shopping List please? What I require is an Excel spreadsheet where I can manually input (and save) what I regularly buy from my local Supermarket over the year and have the facility to select (possible via a check box) and print only the items I require for that week. Ideally there should also be the facility to input the quantity required. Any help would be greatly appreciated Many Thanks Rob -- robertguy 44 Married two kids ------------------------------------------------------------------------ robertguy's Profile...

Handling Multiple Marketing Lists
Hello; We are attempting to import mulitple marketing lists into CRM, and it would be *nice* to be able to keep each list seperate rather than importing them all into the Leads section as one big, monster pile ;D Is this possible? Has anyone figured-out a way to keep multiple marketing lists? Sincerely, Todd M. Taylor Sounds like you are simply trying to break them down. One example would be if you had multiple marketing campaigns. You want a way to show that each lead was assigned to each campaign. One way would be to add a drop down picklist with a list of campaigns etc so even though...

reading and writing xml using a tcp stream
Hi, I am writing a client/server application with a desktop and a pocketPC which transfers a xml string which is to be loaded by a dataset on the client. the server uses this code to prepare and send the xml: Dim stringbuilder As New StringBuilder Dim textwriter As StringWriter = New StringWriter(stringbuilder) Dim xmltextwriter As New Xml.XmlTextWriter(textwriter) xmltextwriter.Formatting = Xml.Formatting.Indented Dataset.WriteXml(xmltextwriter, XmlWriteMode.WriteSchema) 'this is the connection to the client Dim w As New IO.StreamWriter(mobjClient.GetStream) ' the &qu...

selecting data from a list #2
Thank you gentleman (I presume based on the names) for your help. Th sumproduct command worked perfectly. I'm still not sure how, since I' expect that since non-numerical data is assumed to be zero (shouldn' that return a zero? Zero times anything is zero, and the sum o that...nevermind). But you guys saved me some time. This is th solution I was looking for. Dav -- dave0 ----------------------------------------------------------------------- dave05's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1623 View this thread: http://www.excelforum.com...

Default Address List
Hello, Is it possible to change the "Show names from the from the Global Address List" as default to a different list, such as "All Users" list? I know how to change it manually at each workstation. But can it be set at the Exchange server or through group policy, so all existing and new clients default to a different address list? I do not believe it can be set using the standard Outlook admin template via Group Policy so I think you are looking at a scripted solution. Nue "AndyG" <AndyG@discussions.microsoft.com> wrote in message news:390E...

Recently Used File List
Is there any way to clear the recently used file list? On Tue, 9 Feb 2010 11:40:01 -0800, Ed Pyle <EdPyle@discussions.microsoft.com> wrote: >Is there any way to clear the recently used file list? It may differ with the version, but in 2003 and earlier you can use Tools... Options... General; set the number of files to 0; close and open Access; and set it back to however many files you want to see. It's probably similar in 2007, under the "medallion" Access button. -- John W. Vinson [MVP] "Ed Pyle" <EdPyle@discussions.microso...

Xml Serialization #7
Hey There I have a couple of collections that I've written that are based upon the HybridDictionary. Initially I recieved an exception when attempting to serialize instances of these collections informing me that I needed to implement an Add(System.Object) method because the collections inherit from IEnumerable. "You must implement the Add(System.Object) method on PrecisionObjects.Collections.Specialized.StringDictionaryEx because it inherits from IEnumerable." Once I recieved that exception I thought of implementing the IXmlSerializable interface directly however it i...

Exchange 2010 : Create "Contact" and "Distribution list" in AD
Hi folks, with Exchange 2010 user can create Contacts and Distribution List in Active Directory using ECP. I don't have found any documentation about this new very usefull feature. Outlook 2010 support the same feature? Where I found documentation about thie Exchnage 2010 features? Thanks, Lorenzo Soncini 38122 Trento TN Italy I found it pretty easy to Bing that. Here's the first hit: http://www.exchange-genie.com/2009/08/owa-exchange-control-panel-ecp-part1-rbac/ -- Ed Crowley MVP "There are seldom good technological solutions to behavioral problems.&quo...

suggested ways to manipulate XML files in .Net?
Hi everyone, I'm going to manipulate some XML files in my next project-- crawl through the tags, compare if file X has the same nodes as file Y, and if not, what the differences are and who's missing what. I'll also be comparing values between nodes in the two files, for when both documents do have the same named nodes. What .Net classes should I be looking at to accomplish these tasks? Thanks a bunch. Steve Hershoff wrote: > I'm going to manipulate some XML files in my next project-- crawl through > the tags, compare if file X has the same nodes as file Y, and...

xml doc
I have three image groups. I have to create an XML document that models the image groups.Each grouping should include the name and location of the images within the group. How can I do that? seema wrote: > I have three image groups. I have to create an XML document that models the > image groups.Each grouping should include the name and location of the images > within the group. > > How can I do that? What exactly are you looking for, some XML structure to mark up the information? Or for concrete .NET code to create the XML? -- Martin Honnen --- MVP XML http://Jav...