473,385 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Deserialize XML into ArrayList

I am trying to take an XML snipit like the following:

<project>
<stuff1/>
<stuff2/>
</project>
<project>
<stuff1/>
<stuff2/>
</project>
<project>
<stuff1/>
<stuff2/>
</project>

And deserialize it into a simple ArrayList. I would prefer to do this
without a special class to deserialize into, I do have the "project"
class setup. I would also prefer to not wrap these items in a root
node, but can easily do that, and have tried.

Here is my best attempt so far:

XmlSerializer xs = new XmlSerializer( typeof( project) );
ArrayList projects = new ArrayList();
XmlDocument pxml = new XmlDocument();
pxml.LoadXml(inputXml);
foreach (XmlNode project in pxml.ChildNodes)
{
if (!(project is XmlElement))
{
continue;
}
projects.Add(xs.Deserialize(new XmlNodeReader(project)));
}

In most of my attepts I get the following error:

<project xmlns="> was not expected

Thanks,

Richard
Nov 12 '05 #1
0 2831

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Greg | last post by:
I'm writing a class in C# .... I have a collection calls Reports made up of Report objects. I'm trying to deserialize an XML file that looks like : <Reports> <Report> <Title>some title</Title>...
0
by: midnighthell | last post by:
I'm using MemoryStream, and when I send this stream over the network with TCP using NetworkStream , I must Deserialize it, but I don't how to convert from NetworkStream to MemoryStream, I have...
3
by: Just D. | last post by:
Can we deserialize an unknown object? The task is simple - we have many different types of objects stored in ArrayList. We can implement Serialize() method for each object and serialize all...
1
by: Pavel Pavel | last post by:
I have 2 solution to deserialize ArrayList which contains objects I am using for this MemoryStream, but MemoryStream is not functional - I receive always error #End of Stream encountered before...
17
by: Peter | last post by:
How would would you deserialize this example below? Imports System Imports System.Collections Imports System.IO Imports System.Xml.Serialization Public Class App1 Shared Sub Main()
2
by: Thomas S | last post by:
Any suggestions on how to deserialize an object from one line of XML? I'm trying to deserialize multiple objects from one XML document, each object on one line of the file. The serialization is...
4
by: Anbu | last post by:
Hi All, I need to Deserialize the SoapService's SoapEnvelope response object. Here is the Body of the SoapEnvelope received as respone, <q1:serviceResponse...
3
by: sherifffruitfly | last post by:
Hi, I've got a dtd for my xml file according to which, for example, 0 or more <componentelements are permitted. I'd like to take any xml file conforming to this dtd, and deserialize it into a...
3
by: BillyZ313 | last post by:
I am trying to Deserialize an xml to a C# object so i can use it efficently. I have done this with much less complex xml documents so i gave it a shot and it fails on Deserialize call with no good...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.