render xml with dynamic resolution of name element?

Mar 20, 2014 at 3:11 PM
Edited Mar 20, 2014 at 3:11 PM
Is there any way to model this type of xml .
  <Place Parts_Intelli_SiteSettings="Content:1"/>
  <Place Parts_IntelliContentItemId_Edit="Content:after"/>
  <Place Parts_IntelliAssetItemId_Edit="Content:after"/>
  <Place Parts_IntelliListReportWidget_Edit="Content:after"/>
  <Place Parts_IntelliListReportWidget="Content:1"/>
  <Place Parts_IntelliChartReportWidget="Content:1"/>
  <Place Parts_IntelliPivotReportWidget="Content:1"/>
  <Place Parts_IntelliSchedulerReportWidget="Content:1"/>

  <Place Parts_sectiontest2="Content:1"/>
  <Place Parts_sectiontest2_Edit="Content:1"/>
  <Place Parts_sectiontest6="Content:1"/>
  <Place Parts_sectiontest6_Edit="Content:1"/>
My c# classes look like this
    public class PlacementRoot
        private List<PlacementElement> _placementElements;

        [YAXCollection(YAXCollectionSerializationTypes.RecursiveWithNoContainingElement, EachElementName = "Place")]
        public List<PlacementElement> PlacementElements
            get { return _placementElements ?? (_placementElements = new List<PlacementElement>()); }
            set { _placementElements = value; }
    public class PlacementElement

        public string Name { get ; set; }

Is there any way to make the name attribute of placement element dynamic so that it is rendered as the xml shown above .
Mar 21, 2014 at 3:15 AM
I'm not exactly sure how your desired serialization is supposed to work, but see if custom serializers are what you want. Here's a sample:

You can also run the demo application and click on CustomSerializationTests to see the serialized XML.

I think you can create a custom serializer for your PlacementElement class for this purpose; but you are going to be responsible for serizalizing and deserializing the content.
Mar 21, 2014 at 10:36 AM
Thanks for the pointers.