[Solved] want list Object [closed]


Your class ‘ZillowListingConnections’ should be –

[XmlRoot(ElementName = "ListingConnections")]
public class ListingConnections
{
    [XmlElement(ElementName = "MlsIdentifier")]
    public string MlsIdentifier { get; set; }
    [XmlElement(ElementName = "ListingId")]
    public List<string> ListingId { get; set; }
}

Sample Code

public static void Main(string[] args)
{
    var listingConnections = new ListingConnections();
    listingConnections.MlsIdentifier = "test";

    var ListingIds = new List<string>();
    ListingIds.Add("1");
    ListingIds.Add("2");
    ListingIds.Add("3");

    listingConnections.ListingId = ListingIds;

    var xmlSerializer = new XmlSerializer(typeof(ListingConnections));
    xmlSerializer.Serialize(Console.Out, listingConnections);

    Console.WriteLine();
}

Output

<?xml version="1.0" encoding="utf-16"?>
<ListingConnections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <MlsIdentifier>test</MlsIdentifier>
  <ListingId>1</ListingId>
  <ListingId>2</ListingId>
  <ListingId>3</ListingId>
</ListingConnections>

solved want list Object [closed]