Your example should like this:
public class AClass
{
public bool FurtherActionsRequired;
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool FurtherActionsRequiredSpecified;
}
assuming that the field that you're really interested is
"FurtherActionsRequired"
FurtherActionsRequiredSpecified is how .NET handles non-nullable types. For
reference types, if you set the value to null, then the field will not
serialize at all unless you specify otherwise - I don't know how for the
moment, if someone does, feel free to jump in. However, for value types you
can't specify null as the value - i.e. you can't set an integer variable to
null. So .NET uses the above mechanism to say that whether this value-type
field/property should be serialized or not. It's always "<your value-type
variablename>Specified" with the XmlIgnoreAttribute.
Sorry if the explanation isn't any clearer.
Jiho
[quoted text, click to view] "AP" <adamp@indra.com> wrote in message
news:ONibZniLEHA.1892@TK2MSFTNGP10.phx.gbl...
> That doesn't make sense to me at all. Let me simply the example for you.
> Take a class:
>
> public class AClass {
> public bool FurtherActionsRequired;
> public bool FurtherActionsRequiredSpecified;
> }
>
> this class serialized to XML produces the following XML output:
>
> <?xml version="1.0" encoding="utf-8"?>
> <AClass xmlns:xsd="
http://www.w3.org/2001/XMLSchema" > xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"> > <FurtherActionsRequiredSpecified>false</FurtherActionsRequiredSpecified>
> </AClass>
>
> Why does FurtherActionsRequired not get serialized to XML? Is this a bug?
>
> Adam
>
> "Jiho Han" <jiho.han@infinityinfo.com> wrote in message
> news:uRdhw8eLEHA.2532@TK2MSFTNGP10.phx.gbl...
> > The second item is how the serialization implements an integer/boolean
> type
> > element/attribute.
> > If your ElementNameSpecified is false, it doesn't get serialized even if
> > there is a value for ElementName.
> > If you set ElementNameSpecified to true, ElementName will be serialized.
> >
> > I think the reason is that there are no null values for types like
> integer,
> > bool, or Guid. So I guess anything that cannot be assigned null would
use
> > the pattern above.
> >
> > Jiho
> >
> > "AP" <adamp@indra.com> wrote in message
> > news:eeHaRIXLEHA.1312@TK2MSFTNGP12.phx.gbl...
> > > Hello,
> > >
> > > I'm using .NET 1.1. I have a class that has these two members:
> > >
> > > public bool FurtherActionsRequired;
> > >
> > > [System.Xml.Serialization.XmlIgnoreAttribute()]
> > >
> > > public bool FurtherActionsRequiredSpecified;
> > >
> > > If I serialize the class as is, neither of the above items get
> serialized.
> > > If I remove the 2nd item and its ignore attribute,
> FurtherActionsRequired
> > > gets serialized as it should. Is the serializer doing some kind of
> string
> > > matching that would cause this behavior? Why is this happening?
> > >
> > > Thanks,
> > >
> > > Adam
> > >
> > >
> >
> >
>
>