473,395 Members | 2,446 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,395 software developers and data experts.

Deserializing XML into object

Hi,

I'm facing a problem when I have to deserialize an XML into an object. The
typical scenario is as follows:
The XML that I have to deserialize has multiple elements of the same type
(lets say multiple occurences of <abc />) with different inner texts.
Now if I use the already available deserialize method of the XMLSerialize
object, then it returns me only the first element's inner text if I try to
extract in a variable of type string. However, I would like all the element
values to come in as an arraylist (preferably). When I tried deserializing
into a variable of type arraylist, it did not give me anything.
Is there any way to achieve this?

I also tried implementing the IXMLSerializable interface, but am apparently
stuck.
Please help me out!

Nick

Nov 12 '05 #1
1 1199
On Thu, 5 May 2005 01:16:01 -0700, Nick wrote:
Hi,

I'm facing a problem when I have to deserialize an XML into an object. The
typical scenario is as follows:
The XML that I have to deserialize has multiple elements of the same type
(lets say multiple occurences of <abc />) with different inner texts.
Now if I use the already available deserialize method of the XMLSerialize
object, then it returns me only the first element's inner text if I try to
extract in a variable of type string. However, I would like all the element
values to come in as an arraylist (preferably). When I tried deserializing
into a variable of type arraylist, it did not give me anything.
Is there any way to achieve this?

I also tried implementing the IXMLSerializable interface, but am apparently
stuck.
Please help me out!


You might try something like this:

public __gc class ListOfObjects
{
[XmlElementAttribute(Type=__typeof(Line),ElementNam e="Line")]
[XmlElementAttribute(Type=__typeof(Spiral),ElementN ame="Spiral")]
[XmlElementAttribute(Type=__typeof(Curve),ElementNa me="Curve")]
__property ArrayList* get_Collection();
__property void set_Collection(ArrayList* arr);

private:

ArrayList* m_Collection;
};

Now you can serialize/deserialize ListOfObjects that can include Line,
Spiral, and Curve in any order.

--
Daniel
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Nov 12 '05 #2

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

Similar topics

1
by: Justin Armstrong | last post by:
I'm having difficulties deserializing some objects. Consider the following example of what I'm trying to do: ---------------------------------------------------------- class Person { string...
0
by: Kenneth Baltrinic | last post by:
I am getting the following error when deserializing an object that has a couple of dozen dependant objects in its object graph. Anyone who can suggest where I might begin to look to resolve problem...
1
by: Thomas | last post by:
Hi, I implemented a composite pattern which should be serializable to xml. After spending some time in the newsgroups, i finally managed serializing, even with utf-8 instead of utf-16, which...
3
by: Mark McConnell | last post by:
Regarding deserializing XML into a custom object... I've been able to deserialize an XML doc into my custom object and everything works great. The problem I am encountering is when one of the...
4
by: Wayne Wengert | last post by:
Using VB.NET I want to read in an XML file that has an array of objects and then step through the resulting array in code. I build a class to define the structure and I am running code to read in...
5
by: Lucas | last post by:
Well, here's the situation.. It's pretty simple; just that I can't get it to work. I have 2 Executables.. The first one is called CSharp.exe which is a simple WinForm App. I have a single...
0
by: Casey | last post by:
So I'm using XmlSerializer to serialize out a wrapper object that contains an arbitrary number of other objects. The class definitions listed below are made to be very generic. Some of the...
2
by: Phillip Galey | last post by:
I have an object called Place which contains only string properties and has the <Serializable()> flag before the class name declaration. I also have a collection object called Places, which is...
4
by: Andrew E Chapman | last post by:
What happens to an object which is not nothing has another object deserialized into it? I assume that the data in it is completely destroyed by the new object. I am interested because I have...
1
by: =?Utf-8?B?SmVyZW15X0I=?= | last post by:
I am working on an order entry program and have a question related to deserializing nodes with nested elements. The purchase order contains multiple line items which I select using an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.