views:

222

answers:

2

Hi, so I'm serializing an object that contains a List<Object> property, and it serializes it like this:

<Explorer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  <Name>Explorer1</Name>
  <Items>
    <anyType xsi:type="FolderObject">
      <Name>Folder1</Name>
      <Items>
        <anyType xsi:type="MyObject">
          <Name>Object 1</Name>
        </anyType>
      </Items>
    </anyType>
    <anyType xsi:type="MyObject">
      <Name>Object 2</Name>
    </anyType>
  </Items>
</Explorer>

So what I want to do is replace the anyType node with some other name. Is that possible?

Thanks.

A: 

Have you the the XmlElement attribute on the class?

Jeremy
+1  A: 

As Jeremy pointed out:

[XmlElement("ObjectList ")]
public List<Object> ObjectList {get;set;}

Edit: actually, you might want to try:

[XmlArray("ObjectList"), XmlArrayItem("ObjectItem", typeof(ObjectItem))]
public List<Object> ObjectList {get;set;}
Jim Schubert