Very specific serializing C# class to XML


  • I need to serialize my C# class to XML looking something like so:


    What I don't want is 3 classes (request, location, coordinates), I just want 1 class with all changable attributes as root of that class and then added some serialization tags that would create that nested XML, is that at all possible?

    Let's start with the bare class:

    class request
        public int session { get; set; }
        public int page { get; set; }
        public int elements_per_page { get; set; }
        public string zone { get; set; }
        public string region { get; set; }
        public decimal lat { get; set; }
        public decimal lon { get; set; }

    How do I map them so the XML like I described is created? Thanks for your help good people :)
    Wednesday, August 28, 2013 12:12 PM


All replies