Xml Serialize Empty object

  • Thread starter Thread starter Jayesh Modha
  • Start date Start date
J

Jayesh Modha

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
 
See if [XmlElement(IsNullable=true)] will work for you

George.


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
 
Back
Top