Sorry for the horrible title, I wasn't sure what the proper phrasing is.
I've been using this code to parse some XML:
[Serializable()]
public class Report
{
[XmlElement("AttachedFiles")]
public AttachedFiles attachedFiles;
public Report()
{
attachedFiles = null;
}
}
[Serializable()]
[XmlRoot("nodes")]
public class ReportList
{
[XmlElement("node", typeof(Report))]
public Report[] reportList;
}
[Serializable()]
[XmlRoot("AttachedFiles")]
public class AttachedFiles
{
[XmlElement("AttachedFile")]
public List<string> attachedFiles;
}
The XML looks something like this:
<nodes>
<node>
<AttachedFiles>
<AttachedFile>File1</AttachedFile>
<AttachedFile>File2</AttachedFile>
</AttachedFiles>
</node>
</nodes>
The problem I'm having is that this ends up with me having to call Report.attachedFiles.attachedFiles to get the List. Is there a way for me to only call Report.attachedFiles and get the List? I know this is a really minor problem, but it's bothering quite a bit.
EDIT
This is what the code looks like after help from @xDaevax.
[Serializable()]
public class Report
{
[XmlArray(ElementName = "AttachedFiles"), XmlArrayItem(ElementName = "AttachedFile")]
public List<string> AttachedFiles;
public Report()
{
attachedFiles = null;
}
}
[Serializable()]
[XmlRoot("nodes")]
public class ReportList
{
[XmlElement("node", typeof(Report))]
public Report[] reportList;
}
Thanks for the help!