Do Not Show Property?

  • Thread starter Thread starter lucius
  • Start date Start date
L

lucius

I have a public property with this attribute decorating it:

[System.Xml.Serialization.SoapIgnoreAttribute]

but when I convert an object to XML (it inherits from
System.Data.DataTable), it still shows as a Property in the raw XML.

Why does it do this and how can I make it stop? I don't want any
properties to exist in the XML, just the rows from the DataTable.

Thanks.
 
Hi Lucius,

I think the problem you met here is due to the attribute you used.
"SoapIgnoreAttribute" is designed for decorating classes that will be
serialized through SoapFormatter:

#SoapFormatter Class
http://msdn2.microsoft.com/en-us/library/system.runtime.serialization.format
ters.soap.soapformatter(VS.71).aspx

actually, both SoapFormatter and BinaryFormatter are used for binary
serialization. For XML serialization, you should use "XmlIgnoreAttribute"
to exclude property/fields that you do not want to serialize:

#XmlIgnoreAttribute Class
http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlignorea
ttribute.aspx

e.g.[XmlIgnore()]
public int Property2
{
get { return _prop2; }
set {
_prop2 = value;
}
}
<<<<<<<<<<<<<<<<<<<<<<

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Lucius,

Does this helps you or have you any further questions on this? Please feel
free to let me know if there is anything else we can help.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top