473,478 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Xml Serialize Empty object

I am trying to build a soap envelope by looking at object parameter
type.
if my object is empty, it's xml tag is not generated by xml
serializer.
Is there anyway I can generate the xml tag even if the object is
empty.

Thanks,
Jayesh
Oct 23 '08 #1
2 2769
See if [XmlElement(IsNullable=true)] will work for you

George.

"Jayesh Modha" <ja**********@gmail.comwrote in message
news:2e**********************************@r36g2000 prf.googlegroups.com...
>I am trying to build a soap envelope by looking at object parameter
type.
if my object is empty, it's xml tag is not generated by xml
serializer.
Is there anyway I can generate the xml tag even if the object is
empty.

Thanks,
Jayesh
Oct 27 '08 #2
On Oct 26, 4:56 pm, "George" <noem...@comcast.netwrote:
See if [XmlElement(IsNullable=true)] will work for you

George.

"Jayesh Modha" <jayesh.mo...@gmail.comwrote in message

news:2e**********************************@r36g2000 prf.googlegroups.com...
I am trying to build a soap envelope by looking at object parameter
type.
if my object is empty, it's xml tag is not generated by xml
serializer.
Is there anyway I can generate the xml tag even if the object is
empty.
Thanks,
Jayesh
Thanks a lot. I have implemented a custom xml serializer which would
give me the exact soap envelope.
The idea I used is that as follows.
1. Prepared the list of system types that directly converts to
xmltags
2. check the parameter type and see if that directly converts to xml,
then create xml tag for that type.
3. if that type is not directly xml convertible then check if it is
Enum or Array or Class. and do recursive check in Class type.

this idea has given me the exact soap envelope. now I have another
approach, I can still use the solution you have given.
Thanks,
Jayesh Modha
Oct 30 '08 #3

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

Similar topics

0
4496
by: jr | last post by:
Hello, I have got a schema file "myschema.xsd" from my customer for which I must create xml files. I used xsd.exe to create a class for the schema. I fill an object for that class with data...
7
6521
by: Lars-Erik Aabech | last post by:
Hi! I've got problems with serializing my collections of business objects. The objects themselves serialize fine, but the collections fail. I've got the following structure: Base collection...
5
24655
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
2
8855
by: films | last post by:
I understand the concept. Serialization of a class will add all the sub-objects of the class to the stream if there are also serializible. So say I have: class Author {
3
8029
by: Eric | last post by:
I need to send an object between nodes on a network. Each node currently communicates fine with sending strings around but I can't figure out how to deserialize objects using the same basic...
2
2411
by: alexandre martins | last post by:
Every time i try to make Deserialize the computer gives me the folowing error: "End of Stream encountered before parsing was complete" the code that i'm running is simple and is based on an...
8
6834
by: Frank Rizzo | last post by:
How do I serialize Font object into a string that I can store in either INI file or the registry (I know it’s a bad thing, but need to do it nevertheless). Then, also, how do I deserialize it from...
0
2052
by: John Manion via .NET 247 | last post by:
Long Post, thanks for your patience... I have and XML file that looks something like this: <?xml version="1.0" encoding="utf-8" ?> <Settings> <Location> <X>30</X> <Y>40</Y> </Location>...
2
4989
by: Jinsong Liu | last post by:
I have following 3 classes public class MyMainClass { MyCollection<MyObject> m_oMyObjectCollection = null; private string m_sID = string.Empty; public MyCollection<MyObject> Collection {
4
7071
by: =?Utf-8?B?Qnlyb24=?= | last post by:
When I try to serialize an instance of the LocationCell below (note Building field) I get an error in the reflection attempt. If I remove the _Building field it serializes fine. I tried renaming...
0
7027
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
6899
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
7019
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
7067
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...
1
6719
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
5312
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,...
1
4757
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4463
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
166
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.