hello all Currently i am working with xml and have to populate xml file from C# object serializaion.Suppost below is the xml format what i want to do.
<DVD>
<Starring>
<Star position="actor">
Tom Hanks
</Star>
<Star position="actress">
Robin Wright
</Star>
<Title>Forrest Gump</Title>
</Starring>
</DVD>
I have two classes DVD and Star.
Public class DVD
{
string title;
public string Title{get{return title;}set {title=value;}}
List<Star> Starring=new List<Star>();
}
public class Star
{
string star;
string pos;
[XmlAttribute]
public string Position{get{return pos;}set{pos=value;}}
//Actually i don't want this property as a xmlelement
public String StarName
{
get{return star;}
set {star=value;}
}
}
Result from serialization is
<DVD>
<Starring>
<Star position="actor">
<StarName>Tom Hanks</StarName>
</Star>
<Star position="actress">
<StarName>Robin Wright</StarName>
</Star>
<Title>Forrest Gump</Title>
</Starring>
</DVD>
My problem is i don't find the way how to wrap Actor and Actress name without having StarName node.Is there a way to do this?.Any idea would be very appreciate.