Looking to generate an XML file that looks something like this using XML Serialization:
<Root>
<Persons>
<FullName />
<FullName />
<Persons>
</Root>
I'm having trouble getting the FullName to repeat should there be more than one person. Would also like to know how to include attributes in the tags as well.
I've seen things like using XMLArray & XMLArrayItem properties, but not sure how to use these.
Could someone help me out in how to not only create the xml template, but also how the code to create the two FullName items? Every attempt I make I receive an Array Error.
EDIT:
This is what I'm currently trying to do using XmlArray, but get "Object reference not set to an instance of an object.":
Public Class Root
<XmlArrayItem("fullName")>
Public Property first As String()
End Class
Dim x As New Root
x.first(0) = "john"
x.first(1) = "james"
Dim serializer As New XmlSerializer(GetType(Root))
Dim writer As New System.IO.StringWriter
serializer.Serialize(writer, x)
(I used the StringWriter so that once it's been serialized, I can throw it into a text file)