Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Xml Attribute in Xml Array

$
0
0

Hi,

Im trying to serialize a xml document with an array element also have attributes like below:

<HotelList d1="4" d2="3" d3="4"><Hotel><Id>555</Id><Price>50</Price></Hotel><Hotel><Id>556</Id><Price>55</Price></Hotel>
  ....</HotelList>

By creating a custom class name HotelList  i can get attribute array like this:

....    
  [XmlElement]
  public HotelList HotelList { get; set; }

}

public class HotelList
    {
        [XmlAnyAttribute]
        public XmlAttribute[] AttributeList{ get; set; }
}

And i can get the HotelList  like this:

        [XmlArray]
        [XmlArrayItem(ElementName = "Hotel"]
        public Hotel[] HotelList{ get; set; }

Problem is i cant acchive both becouse i have to declare type of the HotelList as custom "HotelList" class or Hotel[] array;

I tried to inherit custom HotelList class for IList and IEnumerable but it doesnt fill AttributeList;

How can i get both array items and attributes,

Thank you in advance.



Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>