Hi
I'm currently having trouble serializing an object to Xml, in the format I
need.
Below is the object definition.
-------------------------------
[Serializable]
public class Folders
{
protected List<PathString _include;
protected List<PathString _exclude;
public Folders()
{
_include = new List<PathString >();
_exclude = new List<PathString >();
}
[XmlArrayItem("I nclude")]
public List<PathString Include
{
get { return _include; }
set { _include = value; }
}
[XmlArrayItem(El ementName="Excl ude",Type=typeo f(PathString))]
public List<PathString Excludes
{
get { return _exclude; }
set { _exclude = value; }
}
}
[Serializable]
public class PathString
{
protected string _path;
[XmlAttribute]
public string Path
{
get { return _path; }
set { _path = value; }
}
public PathString()
{
}
public PathString(stri ng path)
{
_path = path;
}
}
--------------------------
From these objects, I want my Xml output to look like :
<Folders>
<Include Path="Path1"/>
<Include Path="Path2"/>
<Exclude Path="LessTrodd en"/>
</Folders>
However, I am having trouble getting the correct output.
The code above produces the following :
<Folders>
<Include>
<Include Path="Path1"/>
<Include Path="Path2"/>
</Include>
<Excludes>
<Exclude Path="LessTrodd en"/>
</Excludes>
</Folders>
I want to use List (or IList) as I want to bind my object to a DevExpress
TreeList
Does anyone have an idea of how I can get my required output ?
Cheers
Ged
I'm currently having trouble serializing an object to Xml, in the format I
need.
Below is the object definition.
-------------------------------
[Serializable]
public class Folders
{
protected List<PathString _include;
protected List<PathString _exclude;
public Folders()
{
_include = new List<PathString >();
_exclude = new List<PathString >();
}
[XmlArrayItem("I nclude")]
public List<PathString Include
{
get { return _include; }
set { _include = value; }
}
[XmlArrayItem(El ementName="Excl ude",Type=typeo f(PathString))]
public List<PathString Excludes
{
get { return _exclude; }
set { _exclude = value; }
}
}
[Serializable]
public class PathString
{
protected string _path;
[XmlAttribute]
public string Path
{
get { return _path; }
set { _path = value; }
}
public PathString()
{
}
public PathString(stri ng path)
{
_path = path;
}
}
--------------------------
From these objects, I want my Xml output to look like :
<Folders>
<Include Path="Path1"/>
<Include Path="Path2"/>
<Exclude Path="LessTrodd en"/>
</Folders>
However, I am having trouble getting the correct output.
The code above produces the following :
<Folders>
<Include>
<Include Path="Path1"/>
<Include Path="Path2"/>
</Include>
<Excludes>
<Exclude Path="LessTrodd en"/>
</Excludes>
</Folders>
I want to use List (or IList) as I want to bind my object to a DevExpress
TreeList
Does anyone have an idea of how I can get my required output ?
Cheers
Ged