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

Generating XML from an object

Hi,

I have an object of a specific type (this type has properties which
can be complex objects etc...) and I want to serialize this object to
XML so that every property and every child object is serialized, also
the ones that are null.

Does anyone have an idea on how to do that?

Thanks!
Sep 10 '08 #1
8 1245

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!114.entry

Are you talking about serializing without using Xml type-ish attributes?

My entry is very 1.1'ish, fyi.

But I have objects, subcollections, etc, etc. (Aka, not just one level
deep).


<lu***********@hotmail.comwrote in message
news:35**********************************@e39g2000 hsf.googlegroups.com...
Hi,

I have an object of a specific type (this type has properties which
can be complex objects etc...) and I want to serialize this object to
XML so that every property and every child object is serialized, also
the ones that are null.

Does anyone have an idea on how to do that?

Thanks!

Sep 10 '08 #2
lu***********@hotmail.com wrote:
I have an object of a specific type (this type has properties which
can be complex objects etc...) and I want to serialize this object to
XML so that every property and every child object is serialized, also
the ones that are null.

Does anyone have an idea on how to do that?
There is XmlSerializer
http://msdn.microsoft.com/en-us/libr...erializer.aspx
and with .NET 3.0 and later there is also DataContractSerializer
http://msdn.microsoft.com/en-us/libr...erializer.aspx


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Sep 10 '08 #3
On 10 sep, 16:26, Martin Honnen <mahotr...@yahoo.dewrote:
ludwig_stu...@hotmail.com wrote:
I have an object of a specific type (this type has properties which
can be complex objects etc...) and I want to serialize this object to
XML so that every property and every child object is serialized, also
the ones that are null.
Does anyone have an idea on how to do that?

There is XmlSerializerhttp://msdn.microsoft.com/en-us/library/system.xml.serialization.xmls...
and with .NET 3.0 and later there is also DataContractSerializerhttp://msdn.microsoft.com/en-us/library/system.runtime.serialization....

--

* * * * Martin Honnen --- MVP XML
* * * *http://JavaScript.FAQTs.com/
Properties that are null are not serialized this way, and I need these
too in de XML (with default values).
Sep 10 '08 #4
On 10 sep, 16:24, "sloan" <sl...@ipass.netwrote:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!114.entry

Are you talking about serializing without using Xml type-ish attributes?

My entry is very 1.1'ish, fyi.

But I have objects, subcollections, etc, etc. *(Aka, not just one level
deep).

<ludwig_stu...@hotmail.comwrote in message

news:35**********************************@e39g2000 hsf.googlegroups.com...
Hi,
I have an object of a specific type (this type has properties which
can be complex objects etc...) and I want to serialize this object to
XML so that every property and every child object is serialized, also
the ones that are null.
Does anyone have an idea on how to do that?
Thanks!- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -
Yes, just a plain object that has child objects (object hierarchy) of
some of which can be null. But I need everything in the XML, also the
null-values.
Sep 10 '08 #5
Properties that are null are not serialized this way, and I need these
too in de XML (with default values).
Then why not simply make the properties not be null i.e. give them a
default entity?

That way you won't be fighting the system... kinda by definition a
null doesn't *have* sub-values, so trying to write null objects (and
their sub-properties) is counter-intuitive.

Marc
Sep 10 '08 #6
Could you perhaps give a really simple example (a *short* example) of
what you mean? i.e. "I want this object tree [...] to serialize into
this xml [...]"

Marc
Sep 10 '08 #7
Ludwig,

Why not try this one, it is very easy.

http://msdn.microsoft.com/en-us/library/bb387098.aspx

Cor
<lu***********@hotmail.comschreef in bericht
news:35**********************************@e39g2000 hsf.googlegroups.com...
Hi,

I have an object of a specific type (this type has properties which
can be complex objects etc...) and I want to serialize this object to
XML so that every property and every child object is serialized, also
the ones that are null.

Does anyone have an idea on how to do that?

Thanks!
Sep 10 '08 #8
On 10 sep, 17:00, Marc Gravell <marc.grav...@gmail.comwrote:
Could you perhaps give a really simple example (a *short* example) of
what you mean? i.e. "I want this object tree [...] to serialize into
this xml [...]"

Marc
A little clarification: I have written a client app that dynamically
retrieves the WSDL for a running service, creates a proxy for it and
now I'm trying to call the service operations dynamically using the
proxy. This works.

However, the idea is that you can edit the service operation
parameters before invoking the operations. Therefore I need a way to
visualize these parameters, which are plain .NET objects.

To do that I was thinking I could serialize these objects to XML and
display the XML, then you can change the values in the XML and
afterwards the XML is deserialized back into the object and used as a
parameter to invoke the service operation. But serializing an object
results in an XML where only the non-null properties are generated,
and I need all properties to be generated.

Another solution was to build a hierarchy of the object in a treeview
and make every property editable, but this involves a lot of work.

So I'm still not sure what could be the best way to go here...
Sep 11 '08 #9

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

Similar topics

4
by: Axel Straschil | last post by:
Hello! I was fooling around with creating classes for a module with eval, something like: MyModule.py: class Base: init(self, name): self._name = name
1
by: Jack Notarangelo | last post by:
Hello, I am interested in anyone's preference as to creating datasets in code vs generating them using the UI. I know typing is an advantage of the latter method. But any other information...
5
by: Jon Sequeira | last post by:
Does anyone know of a component or class that available for generating updategrams from custom business objects? Ideally I need something that parses a mapping schema, interrogates an object, and...
3
by: Raed Sawalha | last post by:
Hello when I serialize an object an error generated using this function public string SerializeObject(object oClassObject,System.Type oClassType) { XmlSerializer oSerializer = new...
2
by: RichardG | last post by:
I have an object data class that Inherits from a java class and implements System.Runtime.Serialization.ISerializable as I only need to transfer across three properties, string, array of objects...
1
by: louis_la_brocante | last post by:
Dear all, I am having trouble generating a client proxy for a webservice whose methods return a "complex" type. The type is complex in that it is a class whose members are a mix of primitive...
0
SammyB
by: SammyB | last post by:
These are some "random" thoughts about generating random numbers in Visual Basic. Wikipedia will give a better introduction than I, see http://en.wikipedia.org/wiki/Random_number_generator. ...
0
Sakalicek
by: Sakalicek | last post by:
Hi all, I have following problem in my application. I have Web Service and project which uses methods from this Web Service. I created proxy WsProxy by wsdl.exe and put it into that project. But...
4
by: chris.lyon | last post by:
I'm trying to generate visual python objects from django objects and therefore have objects called 'Ring' and 'Cylinder' as django objects and I want to create objects of those names in visual. I...
6
by: vinod allapu | last post by:
Hi boss, I have a gridview, bound to a datasource . Here i want to add columns dynamically containing empty textboxes. Number of columns are variant . The added columns are not bound to...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
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...

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.