Example #1
0
        public static void XMLDemo2()
        {
            CitiesListResponse response = new CitiesListResponse
            {
                Result = new Result
                {
                    Value = "123465",
                    Code  = "001"
                },
                CitiesList = new City[]
                {
                    new City {
                        PinYin = "suzhou", Value = "苏州", HasOutService = "123", Info = "苏州", Population = 123456
                    },
                    new City {
                        PinYin = "wuxi", Value = "无锡", HasOutService = "234", Info = "无锡", Population = 234567
                    },
                    new City {
                        PinYin = "nanjing", Value = "南京", HasOutService = "456", Info = "南京", Population = 345678
                    },
                }
            };
            string str = XmlSerializeHelper.Serializer(response);

            Console.WriteLine(str);
            Console.ReadLine();

            XmlSerializer serializer = new XmlSerializer(typeof(CitiesListResponse));

            serializer.Serialize(Console.Out, response);
            Console.Read();
        }