views:

148

answers:

1

I have an xml as below

<Image Id="23" Name ="image1">
<Used_in Name ="Label1" />
</Image>

Here Image node has been serialized as an object of Image class

[XmlElement(ElementName = "Image")]
public class Image 
{
[XmlAttribute]
public string Name 
{
getter and setter
}

[XmlAttribute]
public string ID 
{
getter and setter
}

}

While deserializing ,but while saving this xml an extra node is also added as child node to it <Used_in Name ="Label1" /> which indicates where all it is used.Is there a way to ignore child nodes while doing XML deserialize???

A: 
[XmlIgnore]
[XmlElement("Used_In")]
public XmlElement UsedIn {get;set;}
John Saunders
Thanks John ,but its not this way,I mean these properties are added in some other modules so i wont be able to set them.Moreove they are added in different class to same xml
Ravisha