Very straight forward but am drawing blanks. Been googling for the last day and a half and haven't found a good example that I can use to make work.
I want it to output like this:Code:[XmlRoot(Namespace = "http://mynamespace.com")] public class Documents { [XmlArray] [XmlArrayItem(typeof(Document))] public ArrayList MyDocuments { get; set; } public void Add(Document document) { MyDocuments.Add(document); } } public class Document { [XmlElement] public int id { get; set; } [XmlElement] public string name { get; set; } }
<?xml version="1.0"?>
<Documents xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://mynamespace.com">
<Document>
<id>1</id>
<name>greg</name>
</Document>
<id>2</id>
<name>jeff</name>
<Document>
</Document>
</Documents>
And here's the main part of just creating the document:
Right now I'm getting an error on the Add method saying it needs a new keyword.Code:Documents myDocs = new Documents(); Document myDoc1 = new Document(); myDoc1.id = 1; myDoc1.name = "greg"; myDocs.Add(myDoc1); Document myDoc2 = new Document(); myDoc2.id = 2; myDoc2.name = "jeff"; myDocs.Add(myDoc2); // Make call to serialize here...
Anyone have any suggestions?




Reply With Quote